为iPhone编译C lib

Dan*_*Dan 4 iphone xcode compilation configure zeromq

我正在尝试编译ZeroMQ C绑定以便能够在iPhone上使用它,这是我的配置选项:

./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

它实际上配置和编译很好,但是当我将它添加到Xcode Frameworks部分时,我收到警告:ld: warning: in /path/to/app/libzmq.a, file was built for unsupported file format which is not the architecture being linked (armv7)并且发现很多符号错误.

如果我将当前活动架构从armv6更改为armv7,警告消息会将其更改为armv6.我究竟做错了什么 ?

谢谢,丹

Jes*_*der 6

听起来你正在为iPhone构建一个通用的armv6/armv7二进制文件(这是默认的,所以这很有意义).这意味着您需要构建一个通用库来链接.构建两个库,然后使用它们lipo来组合这两个库.

例如,构建一个armv6并将其放置在armv6/libfoo.a,而armv7一个在armv7/libfoo.a.然后跑

lipo -arch armv6 armv6/libfoo.a -arch armv7 armv7/libfoo.a -output libfoo.a -create
Run Code Online (Sandbox Code Playgroud)

创建通用库libfoo.a.

  • 谢谢,我终于能够使用这个问题的脚本编译它了 - http://stackoverflow.com/questions/1602182/cross-compile-autotools-based-libraries-for-official-iphone-sdk (2认同)