GNUStep 用shell 编译 object-c

不解释 语句了,以下列出了两种情况 

1  执行 单个 文件 ,如源码:(helloworld.m)

#import <Foundation/Foundation.h>
int main(int argc , const char *argv[]){
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSLog(@"programming is fun!");
	[pool drain];
	return 0;
}

建立 make.sh文件,内容 :

#!/bin/sh
gcc -o $1 $2 -I/GNUstep/System/Library/Headers -fconstant-string-class=NSConstantString -L/GNUstep/System/Library/Libraries -lobjc -lgnustep-base

使用时:sh make.sh helloworld helloworld.m 即可编译成功


2 执行多个文件  Fraction.h ,Fraction.m ,main.m(源码就不贴了,因为这个帖子主要是建立 shell脚本)

A    首先 把main.m生成main.o,sh文件内容:

#!/bin/sh
gcc -fconstant-string-class=NSConstantString -c $1 -I /GNUstep/System/Library/Headers
使用时:sh sh main.m即可生成 main.o文件

B  其次 把Fraction.m生成Fraction.o,sh文件内容:

#!/bin/sh
gcc -c $1 -I /GNUstep/System/Library/Headers
使用时:sh sh Fraction.m即可生成 Fraction.o文件

C   最后生成main.exe文件,sh文件内容:

#!/bin/sh
gcc -o $1 $2 Fraction.o -L /GNUstep/System/Library/Libraries/ -lobjc -lgnustep-base
使用时:sh sh main main.o即可生成 main.exe文件


在执行 多个文件时有些麻烦,但是暂时没有更好的办法来解决,期待有朋友有更好的办法提供出来。


    




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值