example of Makefile to compile a c source file

本文介绍了一个简单的Makefile示例,用于编译C语言源代码。该Makefile包括了目标文件的生成规则及清理命令。通过这个例子,读者可以了解如何设置依赖关系以确保代码修改后能正确重新编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

example of Makefile to compile a c source file

****************************************************************************************

modify_time: modify_time.o
        gcc -o modify_time modify_time.o
modify_time.o: modify_time.c      # the prerequisite 'modify_time.c' CAN'T be omited!!!!! otherwise although modify_time.c modified, it will still prompt 'target is up-to-date' and the modification can't be compiled.
        gcc -c modify_time.c
clean:
        rm -rf *.o modify_time

****************************************************************************************

the below two lines in this Makefile can be omited:

modification can't be compiled.
        gcc -c modify_time.c

在‘跟我一起写Makefile’中有一个Makefile编译多个c文件的例子。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值