오늘 저는이 가이드에 따라 Xcode없이 Objective-C를 배우고 있습니다.
안녕하세요 세계입니다.
makclass.m
#import "makclass.h"
#import <stdio.h>
@implementation MakClass
-(void) age {
printf("Age is %d", age);
}
-(void) setAge: (int) a {
age = a;
}
+(void) say {
printf("Haha");
}
@end
makclass.h
#import <Foundation/NSObject.h>
@interface MakClass: NSObject {
int age;
}
-(void) age;
-(void) setAge: (int) a;
+(void) say;
@end
helloworld.m
#import <stdio.h>
#import "makclass.h"
int main(void) {
printf("Hello World");
MakClass *makclass = [[MakClass alloc] init];
[makclass setAge: 1];
[makclass age];
[MakClass say];
[makclass release];
return 0;
}
그리고 clang helloworld.m
다음과 같은 오류를 제공하십시오.
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MakClass", referenced from:
objc-class-ref in helloworld-XEijke.o
"_objc_msgSend", referenced from:
_main in helloworld-XEijke.o
"_objc_msgSend_fixup", referenced from:
l_objc_msgSend_fixup_alloc in helloworld-XEijke.o
l_objc_msgSend_fixup_release in helloworld-XEijke.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
프레임 워크와 모든 파일도 전달했는지 확인해야합니다.
clang -framework Foundation -o helloworld helloworld.m makclass.m
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다