我终于让GNUstep (在windows上)工作了,它可以编译并运行得很好。但是,每当我尝试使用NSLog时,我都会得到以下错误:
$ gcc -o hello hello.m -I /GNUstep/System/Library/Headers \
> -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base
hello.m: In function 'main':
hello.m:4:5: error: cannot find interface declaration for 'NXConstantString'
我的源码:
#import <Foundation/Foundation.h>
int main(void) {
NSLog(@"hello world");
}
发布于 2011-02-12 12:36:53
它是-
NSLog(@"hello world");
不
NSlog(@"hello world"); // 'l' should be upper case in NSLog
试试这个-
gcc -o hello hello.m -I /usr/lib/GNUstep/System/Library/Headers \
-L /usr/lib/GNUstep/System/Library/Libraries/ -lgnustep-base \
-fconstant-string-class=NSConstantString
发布于 2012-10-10 00:35:22
这很简单,只需在-lgnustep-base
和-fconstant-class=NSConstantString
之间加一个空格
错误的方式:-lgnustep-base-fconstant-class=NSConstantString
正确的方法:-lgnustep-base -fconstant-class=NSConstantString
https://stackoverflow.com/questions/4976351
复制相似问题