2012-01-01 100 views
3

我正在开发用于iPhone的开源项目,并已将项目转换为使用ARC和Apple LLVM 3.0编译器。但是,该项目依赖于使用makefile编译的外部库,因为它是用C语言编写的。目前,它使用GCC进行编译,并且在使其引用ARC引起的Objective-C代码时导致错误,因为某些符号(例如作为@autorelease)在LLVM编译器之前不存在。将GCC makefile脚本转换为LLVM 3.0编译器

但足够。我的问题是如何转换这段代码:

VERSION=4.3 
COPT = -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/System/Library/Frameworks -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/System/Library/PrivateFrameworks -I../../ -I../../Classes/ -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/usr/lib -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/usr/include/ 
COPT += -march=armv7-a -miphoneos-version-min=${VERSION} -I. -O3 -D__IPHONE__ -D_SNESPPC -DASM_SPC700 -DZLIB -DUNZIP_SUPPORT -DOLD_COLOUR_BLENDING -DUSE_SA1 -DSUPER_FX -DLSB_FIRST -DCPU_SHUTDOWN -DVAR_CYCLES 
COPT += -fnested-functions -funsigned-char -ffast-math -fexpensive-optimizations -ftemplate-depth-36 -mstructure-size-boundary=32 -falign-functions=32 -falign-loops -falign-labels -falign-jumps -finline -finline-functions -fno-builtin -fno-common -fomit-frame-pointer -fpeel-loops -fstrength-reduce -funroll-loops -fstrict-aliasing 
GCC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 
GXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-g++-4.2.1 
STRIP = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip 

要使用LLVM编译器吗?我已经试过了修改,以这样的:

VERSION=5.0 
COPT = -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/System/Library/Frameworks -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/System/Library/PrivateFrameworks -I../../ -I../../Classes/ -I/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/clang/3.0/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/usr/lib -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${VERSION}.sdk/usr/include/ 
COPT += -march=armv7-a -miphoneos-version-min=${VERSION} -I. -O3 -D__IPHONE__ -D_SNESPPC -DASM_SPC700 -DZLIB -DUNZIP_SUPPORT -DOLD_COLOUR_BLENDING -DUSE_SA1 -DSUPER_FX -DLSB_FIRST -DCPU_SHUTDOWN -DVAR_CYCLES 
COPT += -fnested-functions -funsigned-char -ffast-math -fexpensive-optimizations -ftemplate-depth-36 -mstructure-size-boundary=32 -falign-functions=32 -falign-loops -falign-labels -falign-jumps -finline -finline-functions -fno-builtin -fno-common -fomit-frame-pointer -fpeel-loops -fstrength-reduce -funroll-loops -fstrict-aliasing 
GCC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang 
GXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ 
STRIP = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip 

但这个目标,而不是为iOS的ARM架构的i386架构,所以我得到的错误,如:

"i386/types.h" not found 

有一个特殊版本铛为ARM?或者我完全错过了什么?

+0

你有一个iPhoneOS3.0.sdk和gcc在你的包含路径下ARC只能在更高的OS上工作? – Mark 2012-01-01 23:55:44

+0

是的,这并没有影响代码,但无论如何我都更新了问题。 – 2012-01-02 00:22:27

回答

3

尝试-arch armv7;您需要使用clang明确指定要为ARM构建的目标。

+1

是的,这是问题。编译时现在有一个新的错误,但我需要对错误究竟是什么进行更多的研究。 – 2012-01-02 01:58:10