NSLog 错误:找不到“NXConstantString”?
我终于让 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");
}
I finally got GNUstep working (on windows), and it compiles and runs fine. However, whenever I try to use NSLog, I get the following error:
$ 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'
My source code:
#import <Foundation/Foundation.h>
int main(void) {
NSLog(@"hello world");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它是 -
不
试试这个 -
如何使用 gcc 编译 Objective C 程序
It is -
not
Try this -
How to compile objective c programs using gcc
请尝试以下操作:
注意
如果没有此命令,它会将常量字符串对象视为类类型
NXConstantString
。运行:
Try the following:
Note
without this command it consider constant string objects as a class type
NXConstantString
.To run:
非常简单,只需在
-lgnustep-base
和-fconstant-class=NSConstantString
之间添加一个空格即可。错误的方式:
-lgnustep-base-fconstant-class=NSConstantString< /code>
正确方法:
-lgnustep-base -fconstant-class=NSConstantString
it's very simple just put a space between
-lgnustep-base
and-fconstant-class=NSConstantString
Wrong way:
-lgnustep-base-fconstant-class=NSConstantString
Right way:
-lgnustep-base -fconstant-class=NSConstantString