2012-01-01 51 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