2012-06-23 80 views
4

我想为ubuntu安装目标c编译器。
本网站用于在Ubuntu上安装GNUstep。 http://www.techotopia.com/index.php/Installing_and_Using_GNUstep_and_Objective-C_on_Linux 然后命令写在下面的顺序在终点码头安装目标c编译器


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. 

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


[email protected]:~$ 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. 

所以,需要一些帮助..

回答

3

尝试运行:

gnustep-config --objc-flags 

自行检查,如果返回错误或适当的GCC标志等

此外,请尝试找到包含目录的位置,并使用-Idir选项将其明确添加到gcc

+0

@sagacious您正在寻找的标志可能是一个'-I <路径/ to/foundatin/headers>'或等价物,它让编译器找到'Foundation.h' – JeremyP

+0

@JeremyP是的,那就是我的意思(看到你的评论后我的编辑:) –

+0

@ManishJhawar yeah.got it.i无法找到路径fondation.h.thanks –