banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[iOS]Xcode5下使用Makefile编译找不到GCC

Xcode5 已经完全抛弃了 GCC 并切换到 LLVM,但并不是完全去除 GCC,只是对 GCC 等编译相关执行文件的位置进行了调整, 如果之前使用的是使用 Makefile 方式命令行编译 iOS APP 的话,Xcode4.6 下编写的脚本可能会无效,需要对 GCC 的执行文件路径进行调整。 调整内容如下 Xcode4.6 之前: /Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/usr/bin Xcode5.0: /Applications/Xcode.app/Contents/Developer/usr/bin 调整后如果出现类似以下错误的话, c preprocessor "/lib/cpp" fails sanity check 建议使用 clang++ 并将 - stdlib=g++ 切换为 libc++ 如果还是不行,那请切换到 Xcode4.6 下进行编译,Xcode4.6 下包含 LLVM GCC 4.2

以下是我用的编译脚本的部分代码

export SDK_VER = "7.0"
export PLATFORM = "iPhoneOS"
export DEV_HOME = "/Applications/Xcode.app/Contents/Developer"
export PLAT_DEV_HOME = "${DEV_HOME}/Platforms/${PLATFORM}.platform/Developer"
export BIN_DIR = "${DEV_HOME}/usr/bin"

7.0 or later?#

if [ "$SDK_VER" == "7.0" ]; then
export BIN_DIR = "${PLAT_DEV_HOME}/usr/bin"
fi
export SDK_ROOT = "${PLAT_DEV_HOME}/SDKs/${PLATFORM}${SDK_VER}.sdk"
export GCC_BIN = "${BIN_DIR}/gcc"

export CFLAGS = ""
export GCC_BASE = " ${GCC_BIN} -Os ${CFLAGS} -Wimplicit \
-isysroot ${SDK_ROOT} \
-F${SDK_ROOT}/System/Library/Frameworks \
-F${SDK_ROOT}/System/Library/PrivateFrameworks "

#armv6,armv7,armv7s,arm64
export GCC = "${GCC_BASE} -arch armv7s"

参考网址 http://www.dotblogs.com.tw/cmd4shell/archive/2013/10/11/123921.aspx

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.