我想在Ubuntu上編譯Objective C中的程序,我已經安裝了GNUstep,設置了所有GNUSTEP_*
環境變量,並安裝了叮噹聲,因爲我讀過gcc無法編譯帶有塊的Objective-C代碼(Objective-C'匿名'函數,只是要清楚:^ { }
)。目標C在Linux Foundation/Foundation.h上與clang編譯鏈接:找不到文件
我能得到什麼,當我運行此命令: clang hello.m -o hello
是:
hello.m:1:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
^
1 error generated.
我想這也: clang -L '/usr/include/GNUstep/Foundation/Foundation.h' hello.m -o hello
哪裏/usr/include/...
是路徑Foundation.h文件在我的系統上;但我仍然得到相同的結果。
如何自動鏈接這些頭文件並編譯Objective-C?
謝謝!
一般情況下,它更容易建立與GNUmakefile,而不是嘗試自己提供所有參數。請參閱http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/。 – echristopherson
此外,'-L'用於指定一個* library * *目錄*,即.so或.dylib文件的位置,該文件的名稱也由'-l'提供。也許你正在考慮'-I/usr/include/GNUstep';這會告訴它* include *文件的根目錄在哪裏。在任何情況下,您都不會提供實際庫或頭文件的完整路徑(也可以提供庫文件的路徑,但很少這樣做)。 – echristopherson
顯然你使用的是gcc objc運行時。哪個IIRC不支持塊。你應該更好地使用libobjc2 – mathk