Compiling C lib for iPhone

I'm trying to compile a ZeroMQ C binding to be able to use it on an iPhone, here are my settings:

./configure --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 CFLAGS="-pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.1.2 -gdwarf-2 -mthumb -I/Library/iPhone/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -mdynamic-no-pic" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib

It actually configures and compiles fine, but when I add it to the Xcode Frameworks section, I get a warning: ld: warning: in /path/to/app/libzmq.a, file was built for unsupported file format which is not the architecture being linked (armv7) and many characters no errors were detected.

If I change the current active architecture from armv6 to armv7, the warning message will change it to armv6. What am I doing wrong?

Thanks Dan

+4
iphone compilation xcode zeromq configure
source share
2 answers

It looks like you are building a universal armv6 / armv7 binary for iPhone (this is the default, so that makes sense). This means that you need to create a universal library that you can link to. Create both libraries, and then use lipo to combine the two.

For example, build armv6 and put it in armv6/libfoo.a , and armv7 in armv7/libfoo.a . Then run

 lipo -arch armv6 armv6/libfoo.a -arch armv7 armv7/libfoo.a -output libfoo.a -create 

to create a universal libfoo.a library.

+6
source share

Given the warning from ld , I assume that you are not compiling the library for the correct platform. And given that you are using configure , I assume that you are trying to compile the library outside of Xcode and then bring it to Xcode later to link it.

Perhaps you can try running configure to configure your headers, but take the actual compilation step inside Xcode?

There are many questions related to compiling third-party (external) C or C ++ libraries for use in iPhone projects.

Creating a static library for iPhone

TiMidity: need help compiling this library for iPhone

0
source share

All Articles