ios - 链接器错误试图链接到 arm,但链接器使用 x86

  显示原文与译文双语对照的内容

我正在尝试交叉编译这个C 库作为一个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而生成的,而不是:,这是我的iOS应用程序将在试图构建项目时链接。


 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

对于前面使用 ./configuremake 生成的每个可执行文件等等。

显然,当我在模拟器上测试代码时,一切都很好,因为没有交叉编译问题。

在make命令中,我甚至尝试直接指定 LDFLAGS,但是它仍然试图与x86连接。 是否有方法告诉编译器链接到指定的体系结构? 我已经查看了 ld的手册页但是我找不到任何可能有帮助的东西。 有什么想法吗?

时间:

Autoconf基本上是我最糟糕的噩梦,所以这个解决方案可能不是"正确",但是希望会阻止你- 它看起来像构建配置没有考虑到在上链接。 它使用 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 

...