似乎有很多關於如何做到這一點的教程,每個教程都略有不同。我希望有人能夠認出我收到的錯誤信息,並指引我朝着正確的方向前進。Linux上的Objective-C編譯錯誤
我的代碼,HM是:
. /usr/share/GNUstep/Makefiles/GNUstep.sh
我嘗試編譯:
gcc `gnustep-config --objc-flags` -lgnustep-base h.m -o hello
,並得到
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
我編譯之前,我在控制檯輸入:
/tmp/ccgLOnpY.o: In function `main': /home/ge/objective-c/h.m:4: undefined reference to `objc_get_class' /home/ge/objective-c/h.m:4: undefined reference to `objc_msg_lookup' /home/ge/objective-c/h.m:4: undefined reference to `objc_msg_lookup' /home/ge/objective-c/h.m:5: undefined reference to `NSLog' /home/ge/objective-c/h.m:6: undefined reference to `objc_msg_lookup' /tmp/ccgLOnpY.o: In function `__objc_gnu_init': /home/ge/objective-c/h.m:8: undefined reference to `__objc_exec_class' /tmp/ccgLOnpY.o:(.data.rel+0x0): undefined reference to `__objc_class_name_NSConstantString' /tmp/ccgLOnpY.o:(.data.rel+0x8): undefined reference to `__objc_class_name_NSAutoreleasePool' collect2: ld returned 1 exit status
有人可以指出我正確的方向嗎?
TIA
你爲什麼不建立與使用GNUmakefile GNUstep的,化妝?這是如何寫一個http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/index.html – 2013-03-07 08:58:26