Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 17, 2010, 04:01 PM   #1
dbrayford
macrumors member
 
Join Date: Feb 2010
mach-o, but wrong architecture

I am getting a strange error message when trying to load a dylib I've just built.

../xxx.dylib: no suitable image found ../xxx.dylib: mach-o, but wrong architecture

I don't understand the error message as I am trying to load the dynamic library on the same machine as I built it on.

David
dbrayford is offline   0 Reply With Quote
Old Mar 17, 2010, 05:12 PM   #2
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: Austin, TX
Open the Terminal and use the 'lipo' command to inspect the binary.

Use: lipo -info /path/to/dylib

It will show you which architectures are in the file. If you only see PPC or something you dont have, that's the problem.

Check your build settings for -arch flags to make sure you are building the dylib properly for your Mac.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote
Old Mar 19, 2010, 07:58 AM   #3
fernandovalente
macrumors 6502
 
Join Date: Aug 2008
Location: Third world **** hole, I mean, Brazil
Send a message via AIM to fernandovalente Send a message via MSN to fernandovalente
Quote:
Originally Posted by dbrayford View Post
I am getting a strange error message when trying to load a dylib I've just built.

../xxx.dylib: no suitable image found ../xxx.dylib: mach-o, but wrong architecture

I don't understand the error message as I am trying to load the dynamic library on the same machine as I built it on.

David
Make sure you're compiling both app and dylib to the same architecture. You may be compiling one for i386 an the other for X86_64.
__________________
Check out the iPhone and Mac apps I developed.
iChat: fernandovalente [a] mac [d] com
Personal blog: www.fvalente.org
E-mail: fernando [a] fvalente [d] org
fernandovalente is offline   0 Reply With Quote
Old Mar 19, 2010, 10:38 AM   #4
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
Thanks,

The compile line I used was:
g++ -c -m64 -I

The link line was:
g++ -m64 -dynamiclib -o xxxx.dylib *.o

I assumed that that it was building and linking to the same architecture.
dbrayford is offline   0 Reply With Quote
Old Mar 19, 2010, 10:53 AM   #5
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
You are compiling your source and linking as a 64-bit binary. But is xxxx.dylib compiled as 64-bit?
robbieduncan is offline   0 Reply With Quote
Old Mar 19, 2010, 12:11 PM   #6
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
I did lipo -info on the *.o files and the output was non-fat files architecture: x86_64

I also performed the lipo -info on all the system dynamic libraries and they all have x86_64 version inside them.
dbrayford is offline   0 Reply With Quote
Old Mar 19, 2010, 12:37 PM   #7
chown33
macrumors 603
 
Join Date: Aug 2009
Please post the actual command-line, and the actual output that shows the error.

When you use placeholders like xxx.dylib, you're removing information that may be critical to solving the problem.
chown33 is offline   0 Reply With Quote
Old Mar 19, 2010, 12:43 PM   #8
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
I added the the option -lx to the link line and this fixed the problem.
I still don't understand how it was linking to the wrong libraries. I am a newbie to makefiles, as I always had a working makefile to work with.

Thanks for all your help, it was most appreciated.
dbrayford is offline   0 Reply With Quote
Old Mar 22, 2010, 04:15 PM   #9
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
I was mistaken and the fix didn't work.

Below is the message from the terminal.

The first part is from the Java JNI as it is trying to load the dylib.

UnsatisfiedLinkError e in loading libAvistoGL.dylib
java.lang.UnsatisfiedLinkError: /Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib: no suitable image found. Did find: /Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib: mach-o, but wrong architecture
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1746)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at AvistoGL.<init>(AvistoGL.java:2716)
at OGLCanvas.<init>(OGLCanvas.java:83)
at CenterPanel.<init>(CenterPanel.java:28)
at AvistoGLTest.<init>(AvistoGLTest.java:32)
at AvistoGLTest.main(AvistoGLTest.java:55)
null
/Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib: no suitable image found. Did find: /Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib: mach-o, but wrong architecture
/Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib: no suitable image found. Did find: /Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib: mach-o, but wrong architecture
dbrayford is offline   0 Reply With Quote
Old Mar 22, 2010, 04:16 PM   #10
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
So what does "lipo -info /Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib" return?
robbieduncan is offline   0 Reply With Quote
Old Mar 22, 2010, 04:19 PM   #11
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
Non-fat file: /Users/u0533750/Desktop/workspace/AvistoGL_Mac/libAvistoGL.dylib is architecture: x86_64
dbrayford is offline   0 Reply With Quote
Old Mar 22, 2010, 04:20 PM   #12
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
OK, cool. And you are trying to use this with JNI so it has to match the architecture of your java executable/process (as it will be loaded into that processes memory space). Can you lipo the java executable you are using?
robbieduncan is offline   0 Reply With Quote
Old Mar 22, 2010, 04:24 PM   #13
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
lipo -info /Users/u0533750/Desktop/workspace/AvistoGL_Mac/AvistoGL.class
lipo: truncated or malformed fat file (offset plus size of cputype (338758144) cpusubtype (1306377) extends past the end of the file) /Users/u0533750/Desktop/workspace/AvistoGL_Mac/AvistoGL.class
dbrayford is offline   0 Reply With Quote
Old Mar 22, 2010, 04:26 PM   #14
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
You misunderstand. That is a class file. It is not an executable (it's java bytecode). The process that must match is the actual java executable. It's a file called java
robbieduncan is offline   0 Reply With Quote
Old Mar 22, 2010, 04:37 PM   #15
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
I have several versions of the executable java. How do I determine which one is being called?

Here is the output from the current

lipo -info /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
Architectures in the fat file: /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java are: ppc7400 i386 x86_64
dbrayford is offline   0 Reply With Quote
Old Mar 22, 2010, 04:38 PM   #16
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
In general type "which java". But, in this case, that may not work. You seem to be running some sort of large system. Does it have start-up script or something? As that may specify the java path...
robbieduncan is offline   0 Reply With Quote
Old Mar 22, 2010, 04:39 PM   #17
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by dbrayford View Post
lipo -info /Users/u0533750/Desktop/workspace/AvistoGL_Mac/AvistoGL.class
lipo: truncated or malformed fat file (offset plus size of cputype (338758144) cpusubtype (1306377) extends past the end of the file) /Users/u0533750/Desktop/workspace/AvistoGL_Mac/AvistoGL.class
If you're using a 'java ...' command-line to run your program, please post the exact command-line.

If you're using a shell script or some other means to start Java, tell us exactly what that is.

Also post the output of this command:
Code:
java -version
Copy and paste the actual output.
chown33 is offline   0 Reply With Quote
Old Mar 22, 2010, 04:40 PM   #18
dbrayford
Thread Starter
macrumors member
 
Join Date: Feb 2010
java -version
java version "1.5.0_20"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_20-b02-315)
Java HotSpot(TM) Client VM (build 1.5.0_20-141, mixed mode, sharing)
dbrayford is offline   0 Reply With Quote
Old Mar 22, 2010, 04:46 PM   #19
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by dbrayford View Post
java -version
java version "1.5.0_20"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_20-b02-315)
Java HotSpot(TM) Client VM (build 1.5.0_20-141, mixed mode, sharing)
This is the 32-bit Java 5 JVM. It can't load x86_64 jni libs.

Is this on 10.5 Leopard, then? Because there isn't a Java 5 on Snow Leopard, only Java 6, unless you've installed the unsupported Java 5 from Leopard.

And what is the command-line or shell-script or whatever you're actually using to run your program?

If you specifically want 64-bit java, you must use the -d64 command-line option. Test case:
Code:
java -d64 -version
chown33 is offline   0 Reply With Quote
Old Jun 11, 2010, 01:34 AM   #20
okdt
macrumors newbie
 
Join Date: Jun 2010
Specify 32bit mode.

This error occurs if you execute 32bit based binary on 64bit platform.

So if you use Java, you may add -d32.
okdt is offline   0 Reply With Quote
Old Aug 31, 2010, 04:46 AM   #21
DJRichCMusic
macrumors newbie
 
Join Date: Aug 2010
I am having a similar problem I wonder if anyone can help me.

My Stack Trace:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/rcook/NetBeansProjects/MPX Print Suite/libEyeOneNative.dylib: no suitable image found. Did find: /Users/rcook/NetBeansProjects/MPX Print Suite/libEyeOneNative.dylib: mach-o, but wrong architecture
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1823)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1746)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at com.mpx.device.eyeone.EyeOneDevice.<init>(EyeOneDevice.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.mpx.plugin.device.PluginDeviceLoader.loadDevices(PluginDeviceLoader.java:52)
at com.mpx.plugin.device.PluginDeviceLoader.getInstance(PluginDeviceLoader.java:29)
at com.mpx.printsuite.TestDevicePlugin.main(TestDevicePlugin.java:22)

Lipo:

Non-fat file: libEyeOneNative.dylib is architecture: i386


Java Version:

java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)



Many thanks in advance.


Regards

Richard
DJRichCMusic is offline   0 Reply With Quote
Old Aug 31, 2010, 04:47 AM   #22
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Have you tried the fix in the thread (run in 32 bit mode)?
robbieduncan is offline   0 Reply With Quote
Old Aug 31, 2010, 05:02 AM   #23
DJRichCMusic
macrumors newbie
 
Join Date: Aug 2010
I have not tried this as the lib works for another java application on the same box.

I just can't tell the difference.
DJRichCMusic is offline   0 Reply With Quote
Old Dec 26, 2010, 11:30 AM   #24
sirkencubin
macrumors newbie
 
Join Date: Dec 2010
help

hi,

I have a similar problem too. I would appreciate if you can help.

Programme gives the following error

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: /Users/akdes/BicAT_v2.22/libisa.jnilib: no suitable image found. Did find: /Users/akdes/BicAT_v2.22/libisa.jnilib: mach-o, but wrong architecture

lipo -info

Non-fat file: /Users/akdes/BicAT_v2.22/libisa.jnilib is architecture: ppc

java -version
java version "1.5.0_26"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_26-b03-376-9M3263)
Java HotSpot(TM) Client VM (build 1.5.0_26-156, mixed mode, sharing)

Thanks a lot
sirkencubin is offline   0 Reply With Quote
Old Dec 27, 2010, 04:50 AM   #25
wrldwzrd89
macrumors G4
 
wrldwzrd89's Avatar
 
Join Date: Jun 2003
Location: Solon, OH
You're trying to run a PPC-only JNILIB on an Intel version of Java. That's doomed to fail.
__________________
iMac Intel (Rev H, 27"), 1TB HDD, 16GB RAM, 10.8.4
wrldwzrd89 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mach-O Linker Error: Duplicate Symbols moonman239 iPhone/iPad Programming 5 Oct 21, 2013 09:08 PM
Architecture software for MBP? Iphone4sinwhite Mac Applications and Mac App Store 2 Mar 20, 2013 08:22 PM
Apple vs. Samsung through architecture? ClassicMacAttak Community Discussion 0 Dec 13, 2012 01:23 AM
Architecture apps for kids Cujo72 Mac Applications and Mac App Store 1 Oct 18, 2012 07:57 PM
Resolved: Architecture for data management phr0ze iPhone/iPad Programming 2 Aug 1, 2012 11:45 AM

Forum Jump

All times are GMT -5. The time now is 11:21 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC