链接器错误-尝试链接到手臂,但使用x86的链接器 [英] Linker error - trying to link against arm, but linker using x86

查看:107
本文介绍了链接器错误-尝试链接到手臂,但使用x86的链接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将此C库交叉编译为iOS库,即,用于armv7机器.我正在使用OSX机器来编译库.该项目设置为使用 Autoconf -这是我正在使用的选项:

I'm attempting to cross compile this C library as an iOS library, i.e., for an armv7 machine. I'm using an OSX machine to compile the library. The project is setup to use Autoconf - here are the options i'm using :

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

这可以编译.该问题发生在链接阶段:

This compiles fine. The problem occurs in the linking stage:

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会引发以下错误:

and so on. The dylib files generated are built for x86 instead of armv7, which is the architecture my iOS application will link against - Xcode throws these errors when trying to build the project :

    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生成的每个可执行文件,依此类推.

and so on for every executable generated earlier using ./configure and make.

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

Obviously, when I test my code on the simulator, all is well, since there are no cross-compilation issues.

我什至尝试直接在make命令中指定LDFLAGS,但它仍在尝试针对x86进行链接.有没有办法告诉编译器链接到指定的体系结构?我已经检查了ld的手册页,但是找不到任何有帮助的内容.有任何想法吗?

I even tried specifying the LDFLAGS in the make command directly, but it's still trying to link against x86. Is there a way to tell the compiler to link against the specified architecture? I've checked the man page for ld, but I couldn't find anything that might help. Any ideas?

推荐答案

Autoconf基本上是我最糟糕的噩梦,因此此解决方案可能不是正确的",但希望可以解除对您的阻止-看起来构建配置未考虑在内在OS X上链接时使用LDFLAGS.它使用LDFLAGS_SHLIB,但是我无法从命令行参数中获取它来覆盖它.试试这个补丁(请注意,我下载了v1.25.29)-我所做的只是将您的参数添加到共享库的现有链接命令的末尾.

Autoconf is basically my worst nightmare, so this solution may not be "correct" but can hopefully unblock you - it looks like the build config does not take into account LDFLAGS when linking on OS X. It uses LDFLAGS_SHLIB, but I wasn't able to get it to override that from a command line argument. Try this patch (note that I downloaded v1.25.29) -- all I did was add your arguments to the end of the existing link command for shared libraries.

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 \

这篇关于链接器错误-尝试链接到手臂,但使用x86的链接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆