无法交叉编译C库for arm(iOS)

时间:2016-08-08 19:07:06

标签: ios c xcode gcc clang

我尝试为iOS开始交叉编译libDSM,从arm64开始。

我已经下载了源代码,并尝试使用以下方法对其进行配置:

export XCODEDIR=$(xcode-select -p)
export DEVROOT=${XCODEDIR}/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS.sdk
export CFLAGS="-arch arm64 -pipe -no-cpp-precomp -isysroot $SDKROOT -mios-version-min=10.0 -I$SDKROOT/usr/include/"
export LDFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=10.0"

./configure --host arm-apple-darwin --prefix $PWD/build/arm64

它因此错误而停止:

configure: error: C preprocessor "/lib/cpp" fails sanity check

configure.log中的错误是:

configure:4504: checking how to run the C preprocessor
configure:4535: gcc -E  conftest.c
In file included from conftest.c:14:
In file included from /Users/pmacro/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include/limits.h:37:
In file included from /Users/pmacro/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/usr/include/limits.h:63:
/Users/pmacro/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/usr/include/sys/cdefs.h:761:2: error: Unsupported architecture
#error Unsupported architecture
 ^

configure.log中可能相关的消息是:

configure:3752: ./conftest

./configure: line 3754: ./conftest: Bad CPU type in executable

请注意,它可以很好地编译x86_64(我建立的平台),但对于任何手臂架构,它都会失败。

我已经看过iOS的交叉编译示例,他们似乎都遵循这些步骤。我正在运行预发布软件(macOS Sierra和Xcode 8),但在Sierra上运行Xcode 7时遇到了同样的问题。谢谢你的帮助。

1 个答案:

答案 0 :(得分:3)

问题是我需要在CPPFLAGS和CFLAGS中指定架构(-arch arm64)。