1
回答
Objective-C 编译的问题
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   


今天想到之前曾经想在Linux下配置Objective-C的环境,正好,我这几天自己配了一台虚拟机Ubuntu 12,就按照这个进行Objective-C的环境的配置.

http://my.oschina.net/linuxyangzhiyong/blog/110943


但是很郁闷的是,编译的时候竟然找不到API,不知道哪里出错了.

@中山野鬼

下面是上图

代码

#import <stdio.h>
int main(int argc, const char *argv[]) {
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSLog(@"Hello World\n");
	[pool drain];
	return 0;
}


robinson@robinson-VirtualBox:~$ sudo apt-get install gcc g++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version.
gcc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
robinson@robinson-VirtualBox:~$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
robinson@robinson-VirtualBox:~$ sudo apt-get install gobjc gnustep gnustep-devel gobjc++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gobjc is already the newest version.
gnustep is already the newest version.
gnustep-devel is already the newest version.
gobjc++ is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
robinson@robinson-VirtualBox:~$ ^C

错误编码是

robinson@robinson-VirtualBox:~$ gcc -fconstant-string-class=NSConstantString -o hello /home/robinson/helloworld.m -l/usr/include/GNUstep -lobjc -lgnustep-base
/home/robinson/helloworld.m: In function ‘main’:
/home/robinson/helloworld.m:3:2: error: unknown type name ‘NSAutoreleasePool’
/home/robinson/helloworld.m:3:30: error: ‘NSAutoreleasePool’ undeclared (first use in this function)
/home/robinson/helloworld.m:3:30: note: each undeclared identifier is reported only once for each function it appears in
/home/robinson/helloworld.m:4:2: error: cannot find interface declaration for ‘NSConstantString’
/home/robinson/helloworld.m:5:2: warning: invalid receiver type ‘int *’ [enabled by default]
/home/robinson/helloworld.m:5:2: warning: no ‘-drain’ method found [enabled by default]
/home/robinson/helloworld.m:5:2: warning: (Messages without a matching method signature [enabled by default]
/home/robinson/helloworld.m:5:2: warning: will be assumed to return ‘id’ and accept [enabled by default]
/home/robinson/helloworld.m:5:2: warning: ‘...’ as arguments.) [enabled by default]

首先我虚拟机上g++ gcc编译环境正常.


举报
Robinson_lu
发帖于4年前 1回/413阅
顶部