Linux的obj文件,【IOS开发】linux 下安装object-c环境。。(初期学习的时候用)

步骤:

1. $ yum -y install gcc-objc

2. 从http://wwwmain.gnustep.org下载GNUstep

Startup和GNUstep Base,并从源码进行安装。

3.. $ export

PATH=$PATH:/usr/GNUstep/System/Tools

4. $ echo "/usr/GNUstep/Local/Library/Libraries/"

>> /etc/ld.so.conf

$ ldconfig

5.$ gcc `gnustep-config --objc-flags`

-L/usr/GNUstep/Local/Library/Libraries -lgnustep-base hello.m -o

hello

6. run program

例子:

#yum install gcc-objc #yum install libpng libpng-devel libtiff libtiff-devel libobjc

libxml2

libxml2-devel libX11-devel libXt-devel libjpeg

libjpeg-devel #wget

ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-startup-0.25.0.tar.gz #tar zxvf gnustep-startup-0.25.0.tar.gz #cd gnustep-startup-0.25.0 #./configure #make #vi ~/.bashrc加入一行: /usr/GNUstep/System/Library/Makefiles/GNUstep.sh 把/usr/GNUstep/Local/Library/Libraries/加到系统的lib路径里面 #vi /etc/ld.so.conf 加入下面一行: /usr/GNUstep/Local/Library/Libraries/ 编译环境配置好,写一个test.m并用下面的命令编译: #gcc `gnustep-config --objc-flags`

-L/usr/GNUstep/Local/Library/Libraries -lgnustep-base test.m

-o test #./test 正常的话会正确执行,如果有报“Unknown time zone name `CST'.”,请修改/etc/localtime

设置正确的系统时区 #vi /etc/localtime 清空之前的内容,加入下面的: TZif2 UTC-8

上面的方法安装不了。。

会出现:-bash: gnustep-config: command not

found

test.m:1:34: error:

Foundation/Foundation.h: No such file or

directory

test.m: In function

‘main’:

test.m:5: error: ‘NSAutoreleasePool’

undeclared (first use in this function)

test.m:5: error: (Each undeclared

identifier is reported only once

test.m:5: error: for each function it

appears in.)

test.m:5: error: ‘pool’ undeclared (first

use in this function)

test.m:7: error: cannot find interface

declaration for ‘NXConstantString’

解决方法:

#yum

install gcc-objc

#yum

install libpng libpng-devel libtiff libtiff-devel libobjc libxml2

libxml2-devel libX11-devel libXt-devel libjpeg

libjpeg-devel

#wget

ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-startup-0.25.0.tar.gz

#tar

zxvf gnustep-startup-0.25.0.tar.gz

#cd

gnustep-startup-0.25.0

#./configure

#make

3. 把gnustep tools目录加入到系统目录下(默认是/usr/GNUstep/System/Tools)

$ export PATH=$PATH:/usr/GNUstep/System/Tools

4. 把编译好的库放在ldconfig的配置文件

$ echo "/usr/GNUstep/Local/Library/Libraries/" >> /etc/ld.so.conf  (这一部上面已经添加,可以忽略)

$ ldconfig

5. 进行编译objective-c.m文件

$ gcc `gnustep-config --objc-flags` -L/usr/GNUstep/Local/Library/Libraries -lgnustep-base hello.m -o hello

6. 运行程序

用了一会觉得太麻烦了,每次都得敲一大串命令编译,然后再运行。

可以设置一个环境变量:

# vi

/etc/profile

export OBJECT=“gcc `gnustep-config --objc-flags`

-L/usr/GNUstep/Local/Library/Libraries -lgnustep-base”

注:修改文件后要想马上生效还要运行# source /etc/profile不然只能在下次重进此用户时生效。

下次就直接:$OBJECT

helloworld.m -o helloworld

。好吧,也可以写一个PHP脚本run.php。。下面是PHP脚本。。

《?php

$name=$_SERVER["argv"][1];

$shell="gcc `gnustep-config --objc-flags`

-L/usr/GNUstep/Local/Library/Libraries -lgnustep-base ".$name.".m

-o ".$name;

shell_exec($shell);

$objrun="./".$name;

shell_exec($objrun);

?》

然后直接敲php

run.php helloworld 就可以运行看结果了。。a4c26d1e5885305701be709a3d33442f.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值