objective-c - NSLog 错误 : Can't find 'NXConstantString' ?

标签 objective-c cocoa gcc nslog gnustep

我终于让 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");
}

最佳答案

是——

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

How to compile objective c programs using gcc

关于objective-c - NSLog 错误 : Can't find 'NXConstantString' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4976351/

相关文章:

cocoa - 写入URL : error handling

objective-c - 在 Cocoa Mac OSX 中设置 FirstResponder 时出现问题

objective-c - 自动核心数据迁移在 Mac OS X 10.5 上失败,但在 10.6 或 10.7 上则不会

c - malloc 和 gcc 优化 2

gcc - 为 ARM 交叉编译 zlib

c++ - gcc 或 makefile 是否有一种机制可以描述源文件的包含文件以替换 #include "xxxx.h"?

iphone - 这是从 NSArray 中删除空白字符串的正确且最有效的方法吗?

ios - SKNode 子类中的 __stack_chk_fail

使用 CoreData 插入数千条数据时 iOS 应用程序崩溃

ios - 如何正确实现从 iOS 应用程序到 watchOS2 复杂功能的设置传输