5
hệ thống:Simple Hello World trong Objective-C với kêu vang và gnustep không biên dịch
64bit Ubuntu Lucid
GNUStep
clang/LLVM
test.m
#import <Foundation/Foundation.h>
int main(int argc, char * argv[]){
NSLog(@"Hello world!\n");
return 0;
}
biên dịch dòng lệnh:
clang -fobjc-gc -I /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include -I /usr/include/GNUstep/ -I /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed/ -L /usr/lib/GNUstep/ -L /usr/lib64/ -fconstant-string-class=NSConstantString -rpath /usr/lib64 -Xlinker -lgnustep-base test.m -o Test
lỗi:
/usr/bin/ld: /usr/lib64//libgnustep-base.so: undefined reference to symbol '__objc_exec_class'
/usr/bin/ld: note: '__objc_exec_class' is defined in DSO /usr/lib64/libobjc.so.2 so try adding it to the linker command line
/usr/lib64/libobjc.so.2: could not read symbols: Invalid operation
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Trong khi sử dụng GCC, nó biên dịch tốt, nhưng clang thì không.
-______________- nó bây giờ mang lại cho tôi một lỗi nói '/ usr/bin/ld: không thể tìm thấy -lobjc'. Tôi đã cài đặt tất cả các mục được liệt kê rồi ... – texasbruce
Tôi đã cập nhật câu trả lời, xem phần chỉnh sửa của tôi. –
'/ usr/bin/ld: /tmp/test-2JGYua.o: undefined tham chiếu đến ký hiệu '__objc_exec_class' /usr/bin/ld: lưu ý: '__objc_exec_class' được định nghĩa trong DSO /usr/lib64/libobjc.so .2 vì vậy hãy thử thêm nó vào dòng lệnh liên kết /usr/lib64/libobjc.so.2: không thể đọc biểu tượng: Thao tác không hợp lệ clang: lỗi: lệnh liên kết không thành công với mã thoát 1 (sử dụng -v để xem lời gọi) ' – texasbruce