views:

144

answers:

2

Hi!

I'm actually developping an application for iPhone and I need to use a library, initially dedicated to a Linux environment. Since I'm using a Mac (with Snow Leopard and Intel Core Duo), I guess it's possible to use this library in my app.

My library has 3 files: a file .h, a file .a and a file .so (both .a and .so are in /Developer/usr/lib). In addition I have included the .h i nmy code and I've added the .a in XCode has a framework (and it works because XCode find the .so compiling).

For your info when I use the command "file" for the file .so, I have: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

When I compile for the Xcode Simulator, I have a warning and an error.
The warning is:
In /Developer/usr/lib/mylib.so, file was built for unsupported file format which is not the architecture being linked (i386)

The error is: "_mylib_fct", referenced from:
-[MyAppAppDelegate applicationDidBecomeActive:] in MyAppAppDelegate.o
Symbol(s) not found
Collect2: ld returned 1 exit status

When I compile for the Device 3.0 with architecture arm6, I also have the same error, but the warning is quite different:
ln /Users/Pablo/MyApp/mylib.a file is not of required architecture

I try to solve this and make the app working with this lib since days, and I don't understand why the compiler is complaining... is it a 32/64 bits issues ? How can I deal with that ?

Your help will be very appreciated. Thx!

+1  A: 

AFAIK If Mac OS is not binary compatible to the specific Linux version, the library should not be usable in your projects.

Also you need two versions, one for the simulator (i386) and one for the device (arm..).

caahab
+1  A: 

Mac OS X is not binary compatible with Linux. It cannot load ELF images, nor does it share the same ABI. It can only load MACH images, e.g.:

file /usr/lib/libcrypto.dylib 
[..]
/usr/lib/libcrypto.dylib (for architecture i386):   Mach-O dynamically linked shared library i386

Read the dlopen man page for details.

diciu
Thanks, thus I have to ask the autor of the library to recreate it using a MACH image ?There's no workaround, since the autor does not support Mac OSX ?
Pablo
If the library author is providing the source code, you could try compiling it on Mac OS X.
diciu