2011-04-03 60 views
1

我想在Linux(Ubuntu)上的Objective-C上構建Hello World。 main.c無法在Objective-C上使用GNUstep構建程序

#import <Foundation/Foundation.h> 

int main(void) 
{ 

    NSLog(@"asdasd"); 
    return 0; 
} 

我不認爲這裏有錯誤。然後,我創建的Makefile:

GNUSTEP_MAKEFILES = /usr/share/GNUstep/Makefiles 

include $(GNUSTEP_MAKEFILES)/common.make 
TOOL_NAME = main 
main_OBJC_FILES = main.m 
include $(GNUSTEP_MAKEFILES)/tool.make 

然後我運行的 「make」:

This is gnustep-make 2.2.0. Type 'make print-gnustep-make-help' for help. 
Making all for tool main... 
make[1]: GNUmakefile: no such file or directory 

我怎樣才能解決這個問題?

+3

也許您需要將您的Makefile重命名爲GNUmakefile,如錯誤所示... – Macmade 2011-04-03 16:53:48

回答

5

在Ubuntu系統上安裝GNUstep庫和工具很簡單,只需要sudo apt-get install gnustep gnustep-devel,你就全部設置好了(認真的說,就我所知,Apt是最簡單的安裝方式軟件 - 只要它在存儲庫中)。 原來我已經命名它GNUMakefile,而我應該命名它GNUmakefile

source.m

#import <Foundation/Foundation.h> 
int main(void) 
{ 
    NSLog(@"asdasd"); 
    return 0; 
} 

GNUmakefile:

GNUSTEP_MAKEFILES = /usr/share/GNUstep/Makefiles 

include $(GNUSTEP_MAKEFILES)/common.make 
TOOL_NAME = app 
app_OBJC_FILES = source.m 
include $(GNUSTEP_MAKEFILES)/tool.make 

我可以運行它。

[email protected]:~/ObjectiveC$ make 
This is gnustep-make 2.6.0. Type 'make print-gnustep-make-help' for help. 
Making all for tool app... 
Compiling file source.m ... 
Linking tool app ... 

[email protected]:~/ObjectiveC$ ./obj/app 
2011-11-22 18:01:21.285 app[8042] asdasd 
相關問題