我一直在为iOS进行各种库的交叉编译,直到iOS5之前都没有问题。问题是,iOS5 SDK不再包含GNU gcc编译器,只有llvm和clang可用。
我的问题是,我无法完成任何库的'configure'脚本运行。它总是失败并显示以下信息:
configure: error: C preprocessor
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" fails sanity check
gcc只是指向LLVM编译器的符号链接。如果我将其设置为clang,它会产生相同的错误。(只是语法错误表现更好)
这里是config.log的重要部分:
configure:3338: checking how to recognise dependent libraries
configure:3514: result: pass_all
configure:3993: checking how to run the C preprocessor
configure:4111: result: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
configure:4135: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -B/Developer/Platforms/iPhoneOS.platform/Developer/usr -arch armv7 -miphoneos-version-min=5.0 -gdwarf-2 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system conftest.c
conftest.c:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'error'
configure:4141: $? = 1
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME "expat"
| #define PACKAGE_TARNAME "expat"
| #define PACKAGE_VERSION "2.0.1"
| #define PACKAGE_STRING "expat 2.0.1"
| #define PACKAGE_BUGREPORT "expat-bugs@libexpat.org"
| /* end confdefs.h. */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
| Syntax error
configure:4135: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -B/Developer/Platforms/iPhoneOS.platform/Developer/usr -arch armv7 -miphoneos-version-min=5.0 -gdwarf-2 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system conftest.c
conftest.c:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'error'
configure:4141: $? = 1
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME "expat"
| #define PACKAGE_TARNAME "expat"
| #define PACKAGE_VERSION "2.0.1"
| #define PACKAGE_STRING "expat 2.0.1"
| #define PACKAGE_BUGREPORT "expat-bugs@libexpat.org"
| /* end confdefs.h. */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
| Syntax error
configure:4210: error: C preprocessor "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" fails sanity check
See `config.log' for more details.
这是我的环境。可能有些冗余,但它在iOS4.X上可以很好地运行。
# Defines
DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
SDKROOT=$DEVROOT/SDKs/iPhoneOS5.0.sdk
# BUILD STUFF
export CXXFLAGS="-B/Developer/Platforms/iPhoneOS.platform/Developer/usr -arch armv7 -miphoneos-version-min=5.0 -gdwarf-2 -mthumb -isysroot $SDKROOT -L$SDKROOT/usr/lib/system"
export CPPFLAGS="$CXXFLAGS"
export CFLAGS="$CXXFLAGS"
export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
export CXXCPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++
#export CXX=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++
export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
export LD=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld
export RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib
export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
export STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip
export LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool
export INSTALL_DIR=/Users/mriedel/MPI/CrossCompiling/armv7_dev_install
export CPATH=$INSTALL_DIR/include
export LIBRARY_PATH=$INSTALL_DIR/lib
我已经尝试了数周,但没有任何进展。我认为其他人肯定也遇到过这个问题。但是谷歌没有带来任何有用的结果。有一段时间,我试图使用gas-preprocessor.pl,但同样没有成功。
啊,我的配置调用总是类似于这样:
./configure --prefix=$INSTALL_DIR --disable-shared --enable-static --host=arm-apple-darwin
我想指出的是,所有使用配置脚本的库都存在这个问题。列举几个例如:apr、apr-util、expat、log4cxx等等...... 我甚至不确定期望的输出应该是什么。代码中只有一个奇怪放置的“语法错误”。难怪它不能编译 :)
非常感谢提供进一步的帮助和提示。