背景:在windows下装的GNUStep 
问题:先写了一个Person的类,源文件是"Person.h",然后写了一个类的实现,源文件是"Person.m", 然后写了个main.m文件, 
main.m文件主要代码 #import "Person.h" 
int main(int argc,const char *argv[]){    
    Person *p=[[Person alloc]init]; 
    ...... 
    [p release]; 
} 最后在shell里编译,输入以下命令 :gcc -c main.m -fconstant-string-class=NSConstantString -I/GNUstep/System/Library/Headers   成功编译出main.o文件。接着输入一下命令:  gcc -o main main.o -L/GNUstep/System/Library/Libraries/  -lobjc -lgnustep-base    就出现了 undefined reference to '_objc-class-name-Person'  collect2 ld return 1 exit status的错误,也没有出来main.exe文件 有哪位高手帮一下忙! 

解决方案 »

  1.   

    少import了吧,对objecttive-C的看过一些,应该引入foundation吧
      

  2.   

    添加一句#import "Person.m" 应该就好了。
    我最近也在学习object c,呵呵,大家以后可以多多交流。
    关于这种问题,详见http://stackoverflow.com/questions/1558462/compiling-objective-c-project-on-linux-ubuntu,讲的比较详细。