2012-06-23 79 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 –