【发布时间】:2012-07-06 15:56:48
【问题描述】:
我是 Iphone 编程的初学者。我正在尝试编译(ubuntu)。
#import <Foundation/Foundation.h>
int main (void)
{
NSLog (@"Executing");
return 0;
}
我编译了它,但出现以下错误
subhash@subhash-Lenovo-G570:~/grit/iphone/mac$ gcc -lgnustep-base -lpthread -lob
jc -lm -I/usr/local/include/GNUstep -I/usr/include/GNUstep -fconstant-string-cla
ss=NSConstantString hello.m -o hello
In file included from /usr/include/GNUstep/Foundation/NSClassDescription.h:30:0,
from /usr/include/GNUstep/Foundation/Foundation.h:50,
from hello.m:1:
/usr/include/GNUstep/Foundation/NSException.h:42:2: error: #error The current se
tting for native-objc-exceptions does not match that of gnustep-base ... please
correct this.
我按照http://ubuntuforums.org/showthread.php?p=5593608 作为参考。
我评论了 NSException.h 的#error 指令,问题就解决了。现在我遇到了新的错误。
/tmp/ccQlI9wJ.o: In function `main':
hello.m:(.text+0x11): undefined reference to `NSLog'
/tmp/ccQlI9wJ.o: In function `__objc_gnu_init':
hello.m:(.text+0x2a): undefined reference to `__objc_exec_class'
/tmp/ccQlI9wJ.o:(.data+0x40): undefined reference to `__objc_class_name_NSConsta
ntString'
collect2: ld returned 1 exit status
【问题讨论】:
-
我不得不在 NSException.h 中注释掉那个错误,没有其他工作。
-
如何正确编译。
-
这就是我刚刚写的。注释掉头文件中的#error指令。
-
谢谢,问题已解决,但我遇到了新错误。
-
我认为避免所有软件包并直接从主干安装 GNUstep 是一个更好的主意。并使用铿锵声。或者用这个lists.gnu.org/archive/html/discuss-gnustep/2012-10/…