GNUSTEP_MAKEFILES=/usr/lib64/GNUstep/Makefiles
export GNUSTEP_MAKEFILES
#import <Foundation/Foundation.h>
int main(int argc, char * argv[]){
NSLog(@"Hello world!\n");
return 0;
}
gcc `gnustep-config --objc-flags` -L/lib64/libobjc.so.4 -lgnustep-base hello.m -o hello
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/libgnustep-base.so: undefined reference to symbol 'objc_msg_lookup'
/usr/bin/ld: note: 'objc_msg_lookup' is defined in DSO /lib64/libobjc.so.4 so try adding it to the linker command line
/lib64/libobjc.so.4: could not read symbols: 无效的操作
collect2: 错误:ld 返回 1
--------------------------------------------------------------------------------------------------------------------------
$gcc hello.m `gnustep-config --objc-flags` -lobjc -lgnustep-base -o hello
$ ./hello
2013-11-18 22:16:42.869 hello[8531] Hello,world!
参考:
http://stackoverflow.com/questions/13446450/simple-hello-world-in-objective-c-with-clang-and-gnustep-does-not-compile