我试图将this C library交叉编译为iOS库,即用于armv7机器。我正在使用OSX机器来编译库。该项目设置为使用Autoconf - 以下是我使用的选项:
./configure --host=arm-apple-darwin --prefix ~/dev/xmlrpc-c-1.25.28/iOS_bin_arm CFLAGS="-arch armv7s -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -miphoneos-version-min=4.0" --disable-curl-client --disable-cplusplus LDFLAGS='-arch armv7s -miphoneos-version-min=4.0 --sysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk'
编译好。问题发生在链接阶段:
ld: warning: ignoring file parse_datetime.osh, file was built for armv7s which is not the architecture being linked (x86_64): parse_datetime.osh
ld: warning: ignoring file parse_value.osh, file was built for armv7s which is not the architecture being linked (x86_64): parse_value.osh
ld: warning: ignoring file resource.osh, file was built for armv7s which is not the architecture being linked (x86_64): resource.osh
ld: warning: ignoring file trace.osh, file was built for armv7s which is not the architecture being linked (x86_64): trace.osh
ld: warning: ignoring file version.osh, file was built for armv7s which is not the architecture being linked (x86_64): version.osh
ld: warning: ignoring file xmlrpc_data.osh, file was built for armv7s which is not the architecture being linked (x86_64): xmlrpc_data.osh
ld: warning: ignoring file xmlrpc_datetime.osh, file was built for armv7s which is not the architecture being linked (x86_64): xmlrpc_datetime.osh
ld: warning: ignoring file xmlrpc_string.osh, file was built for armv7s which is not the architecture being linked (x86_64): xmlrpc_string.osh
等等。生成的dylib文件是为x86而不是armv7构建的,这是我的iOS应用程序将链接的架构--Xcode在尝试构建项目时抛出这些错误:
ld: warning: ld: warning: ld: warning: ignoring file ~/dev/xmlrpc-c-1.25.28/iOS_bin_arm/lib/libxmlrpc_server_pstream++.7.25.dylib, file was built for x86_64 which is not the architecture being linked (armv7): ~/dev/xmlrpc-c-1.25.28/iOS_bin_arm/lib/libxmlrpc_server_pstream++.7.25.dylib
ignoring file ~/dev/xmlrpc-c-1.25.28/iOS_bin_arm/lib/libxmlrpc_server_cgi++.dylib, file was built for x86_64 which is not the architecture being linked (armv7):~/dev/xmlrpc-c-1.25.28/iOS_bin_arm/lib/libxmlrpc_server_cgi++.dylib
对于之前使用./configure
和make
生成的每个可执行文件,等等。
显然,当我在模拟器上测试我的代码时,一切都很顺利,因为没有交叉编译问题。
我甚至尝试直接在make命令中指定LDFLAGS,但它仍在尝试链接x86。有没有办法告诉编译器链接指定的架构?我已经查看了ld
的手册页,但我找不到任何可能有用的内容。有任何想法吗?
答案 0 :(得分:1)
Autoconf基本上是我最糟糕的噩梦,所以这个解决方案可能不是"正确"但是可以希望解锁你 - 看起来构建配置在OS X上链接时没有考虑LDFLAGS。它使用LDFLAGS_SHLIB,但是我无法从命令行参数中覆盖它。试试这个补丁(注意我下载了v1.25.29) - 我所做的就是将你的参数添加到共享库的现有链接命令的末尾。
neals-mbp: ~/xmlrpc-c-1.25.29> diff config.mk.in config.mk.in2
297c297
< LDFLAGS_SHLIB = -dynamiclib -undefined suppress -single_module \
---
> LDFLAGS_SHLIB = -dynamiclib -undefined suppress -single_module -arch armv7s -miphoneos-version- min=4.0 --sysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk \