gpt4 book ai didi

objective-c - 安装 objective c 编译器

转载 作者:搜寻专家 更新时间:2023-10-30 19:44:36 27 4
gpt4 key购买 nike

我想为 ubuntu 安装 objective c 编译器。
该站点用于在 ubuntu 上安装 GNUstep。 http://www.techotopia.com/index.php/Installing_and_Using_GNUstep_and_Objective-C_on_Linux然后在终端中按以下顺序编写命令-


sudo apt-get install gnustep  
sudo apt-get install gnustep-devel

然后,我写了我的示例代码并保存为hello.m


#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSLog (@"hello world");
[pool drain];
return 0;
}

然后,我在终端输入


. /usr/share/GNUstep/Makefiles/GNUstep.

gcc `gnustep-config --objc-flags` -lgnustep-base hello.m -o hello  

然后,出现了一条错误信息


gcc: gnustep-config --objc-flags: No such file or directory
hello.m:1:23: fatal error: Foundation.h: No such file or directory
compilation terminated.

然后,我写了


sudo apt-get install gobjc  

然后,终端显示


Reading package lists... Done
Building dependency tree
Reading state information... Done
gobjc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 205 not upgraded.

然后,我再次编译,但它再次显示相同的错误。


hp@ubuntu:~$ gcc 'gnustep-config --objc-flags' -lgnustep-base hello.m -o hello
gcc: gnustep-config --objc-flags: No such file or directory
hello.m:1:23: fatal error: Foundation.h: No such file or directory
compilation terminated.

所以,需要一些帮助..

最佳答案

尝试运行:

gnustep-config --objc-flags

自行检查是否返回错误或适当的 gcc 标志等。

此外,尝试找到 include 目录的位置并使用 -Idir 选项将其显式添加到 gcc

关于objective-c - 安装 objective c 编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11170622/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com