Foundation.h 错误
我在 Linux(Ubuntu) 中学习 Objective-C,但是当我尝试编译需要 Foundation 标头的应用程序时,出现错误,提示找不到该文件,但我已经安装了 GNUstep 开发包(gnustep-devel)。这是我的代码:
// Fraction.h
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
int numerator;
int denominator;
}
- (void) print;
- (void) setNumerator: (int) n;
- (void) setDenominator: (int) d;
- (void) numerator;
- (void) denominator;
@end
这是控制台日志:
ubuntu@eeepc:~$ gcc main.m -o frac -lobjc
In file included from main.m:3:
Fraction.h:2:26: error: objc/NSObject.h: No such file or directory
In file included from main.m:3:
Fraction.h:4: error: cannot find interface declaration for ‘NSObject’, superclass of ‘Fraction’
ubuntu@eeepc:~$
我需要做什么?
I learning Objective-C in Linux(Ubuntu), but when i tryed to compile my application that needs the Foundation headers i got an error saying that the file cannot be found, but i have installed the GNUstep development package(gnustep-devel). Here is my code:
// Fraction.h
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
int numerator;
int denominator;
}
- (void) print;
- (void) setNumerator: (int) n;
- (void) setDenominator: (int) d;
- (void) numerator;
- (void) denominator;
@end
And here is the console log:
ubuntu@eeepc:~$ gcc main.m -o frac -lobjc
In file included from main.m:3:
Fraction.h:2:26: error: objc/NSObject.h: No such file or directory
In file included from main.m:3:
Fraction.h:4: error: cannot find interface declaration for ‘NSObject’, superclass of ‘Fraction’
ubuntu@eeepc:~$
What i need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你是怎么编译的?对我来说,我为我的应用程序创建了一个
GNUMakefile
makefile(请参阅 此处),然后运行source /usr/share/GNUstep/Makefiles/GNUstep.sh
,然后运行make
。how are you compiling it? For me, I create a
GNUMakefile
makefile for my application (see here), and then I runsource /usr/share/GNUstep/Makefiles/GNUstep.sh
and thenmake
.适用于 Windows 的 GNUstep 安装过程
如果您要下载 gnustep-system,请记住一件事对于任何版本,您都必须下载相同版本的 gnustep-core。
例如,如果您已经下载了 gnustep-setup-0.22.1-setup.exe,那么您必须下载 gustep-core-0.22.1-setup.exe,否则您的代码将无法运行。
将其保存为 C:/GNUstep/home/foldername 中的 hello.m
请记住,foldername 是您第一次启动 shell 时的名称,它会创建环境并在 C:/GNUstep/home 文件夹中按您的计算机名称创建一个文件夹。所以不要惊慌。好的,
最后您将能够在 shell 中看到输出。
恭喜您成功编写了第一个 Objective C 程序。
需要任何说明请写信给我:[电子邮件受保护]
GNUstep Installation Process For Windows
Remember one thing if you are downloading gnustep-system of any version you must have to download the same version for gnustep-core.
For example if you have downloaded gnustep-setup-0.22.1-setup.exe then you must have to download gustep-core-0.22.1-setup.exe otherwise your code will not run.
save it as hello.m in your C:/GNUstep/home/foldername
Remember foldername is the name when you first time start the shell it create the envoirment and make a folder by the name of your computer name in C:/GNUstep/home folder. So don’t be panic.Okay
Finally you will be able to see the output in the shell.
Conguratulation you wrote your first Objective C program successfully.
Need any clarification write me to : [email protected]
我在存储库中进行了搜索,然后安装了基础库,现在一切正常。
谢谢。
I've searched at the repository and then i installed the foundation lib, now all is working.
Thanks.