使用shell脚本编译C程序 [英] using a shell script to compile your C programs

查看:746
本文介绍了使用shell脚本编译C程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你觉得这个方法有什么问题吗?例如。我写了一个shell

脚本a.sh包含:


cc -o test file1.c file2.c file3.c

然后执行shell脚本(sh a.sh)来编译并创建

可执行文件。这个方法和写一个

make文件有什么区别?

解决方案

pereges写道:
< blockquote class =post_quotes>
你觉得这个方法有什么问题吗?例如。我写了一个shell

脚本a.sh包含:


cc -o test file1.c file2.c file3.c

然后执行shell脚本(sh a.sh)来编译并创建

可执行文件。这个方法和写一个

make文件有什么区别?



这里不是主题,请尝试comp.unix.programmer


但是:使用makefile会确保目标得到每当源发生变化(即比目标更新)时,重新构建

,一个shell

脚本总是无条件地编译,无论它是否是

实际上是必要的。


再见,Jojo


5月9日,08:14,Joachim Schmitz < nospam.j ... @ schmitz-digital.de>

写道:


pereges写道:


你觉得这个方法有什么问题吗?例如。我写了一个shell

脚本a.sh包含:


cc -o test file1.c file2.c file3。 c


然后执行shell脚本(sh a.sh)来编译并创建

可执行文件。这个方法和写一个

make文件有什么区别?



这里不是主题,请尝试comp.unix.programmer



我认为这很多这里比主题更好......

comp.unix.programmer基本上他是

询问编译方法不是

如何编写shell脚本和makefile>

不是特定于Unix的。


但是:使用makefile会确保目标重新构建

每当源发生变化(即比目标更新)时,shell

脚本总是无条件地编译,无论它是否实际上是必要的。



这是一个热门回复。


pereges说:


你觉得这个方法有什么问题吗?例如。我写了一个shell

脚本a.sh包含:


cc -o test file1.c file2.c file3.c

然后执行shell脚本(sh a.sh)来编译并创建

可执行文件。这个方法和写一个

make文件有什么区别?



使文件保存在打字和拼写上。你更愿意

记住并输入:这......


Do you see anything wrong about this method ? For eg. I write a shell
script a.sh containing :

cc -o test file1.c file2.c file3.c

and then execute the shell script ( sh a.sh) to compile and create the
executable. What is the difference between this method and writing a
make file ?

解决方案

pereges wrote:

Do you see anything wrong about this method ? For eg. I write a shell
script a.sh containing :

cc -o test file1.c file2.c file3.c

and then execute the shell script ( sh a.sh) to compile and create the
executable. What is the difference between this method and writing a
make file ?

Not really topical here, try comp.unix.programmer

But: using a makefile would ensure that the target gets build afresh
whenever the source has changed (i.e is newer than the target), a shell
script would always compile, unconditionally, regardless whether it is
acctually neccessary.

Bye, Jojo


On 9 May, 08:14, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:

pereges wrote:

Do you see anything wrong about this method ? For eg. I write a shell
script a.sh containing :

cc -o test file1.c file2.c file3.c

and then execute the shell script ( sh a.sh) to compile and create the
executable. What is the difference between this method and writing a
make file ?


Not really topical here, try comp.unix.programmer

I think it''s a lot more topical here than
comp.unix.programmer Essentially he''s
asking about compiling methodology not
how to write a shell script and makefiles
are not Unix specific.

But: using a makefile would ensure that the target gets build afresh
whenever the source has changed (i.e is newer than the target), a shell
script would always compile, unconditionally, regardless whether it is
acctually neccessary.

And this is a topical reply.


pereges said:

Do you see anything wrong about this method ? For eg. I write a shell
script a.sh containing :

cc -o test file1.c file2.c file3.c

and then execute the shell script ( sh a.sh) to compile and create the
executable. What is the difference between this method and writing a
make file ?

Make files save on typing and braining. Which would you rather have to
remember and type: this...


这篇关于使用shell脚本编译C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆