黑马程序员技术交流社区

标题: 这个问题怎样解决??? [打印本页]

作者: 马志华    时间: 2015-1-12 22:58
标题: 这个问题怎样解决???
  1. #import <Foundation/Foundation.h>
  2. @interface Car :NSObject
  3. {
  4.     @public
  5.     int wheels;
  6.     int speed;
  7. }
  8. -(void)run;
  9. void test(int w ,int s);
  10. @end

  11. @implementation Car
  12. -(void)run
  13. {
  14.     NSLog(@"%d个轮子,时速为%dKm/h的车子跑起来了",wheels,speed);
  15. }

  16. @end
  17. void test(int w ,int s)
  18. {
  19.     w =20;
  20.     s =5;
  21. }


  22. int main()
  23. {
  24.     Car *p=[Car new];
  25.     p->wheels = 4;
  26.     p->speed = 200;
  27.     test(p->wheels,p->speed);
  28.     [p run];
  29.     return 0;
  30. }
复制代码


编译连接时出现问题:
localhost:11-OC mazhihua$ cc 09-OC对象和函数.m
Undefined symbols for architecture x86_64:
  "_NSLog", referenced from:
      -[Car run] in 09-OC对象和函数-83cd7b.o
  "_OBJC_CLASS_$_NSObject", referenced from:
      _OBJC_CLASS_$_Car in 09-OC对象和函数-83cd7b.o
  "_OBJC_METACLASS_$_NSObject", referenced from:
      _OBJC_METACLASS_$_Car in 09-OC对象和函数-83cd7b.o
  "___CFConstantStringClassReference", referenced from:
      CFString in 09-OC对象和函数-83cd7b.o
  "__objc_empty_cache", referenced from:
      _OBJC_METACLASS_$_Car in 09-OC对象和函数-83cd7b.o
      _OBJC_CLASS_$_Car in 09-OC对象和函数-83cd7b.o
  "_objc_msgSend", referenced from:
      _main in 09-OC对象和函数-83cd7b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
localhost:11-OC mazhihua$


看不懂问题,不会解决,求指教!!




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2