Home > 语言编程, 零敲碎打 > [iOS]Xcode5下使用Makefile编译找不到GCC

[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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

  1. No comments yet.
  1. No trackbacks yet.