Makefile显示“make: Nothing to be done for xxxx”的解决方法

本文介绍了在Makefile中遇到make: Nothing to be done for `xxxx'错误的原因及解决办法。通常是因为target名称与现有文件或目录冲突导致。通过使用.PHONY指令可以有效避免这一问题。

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

1. 问题

添加一个Makefile的target的时,总会出现“make: Nothing to be done for `xxxxx’”的提示,而书写语法表面正确。

2. 原因

Makefile的target和目录或文件名字冲突。

A phony target is one that is not really the name of a file;
rather it is just a name for a recipe to be executed when you make an explicit request.
There are two reasons to use a phony target:
to avoid a conflict with a file of the same name, and to improve performance.
If you write a rule whose recipe will not create the target file, the recipe will be executed every time the target comes up for remaking.

3. 总结

GNU默认Makefile的target是一个文件(或目录)。
它会先检测同级目录下是否已存在这个文件,如果存在,则会abort掉make 进程,并提示

make: Nothing to be done for `xxxx’

这种情况需要.PHONY来避免问题的出现,phony的意思是“赝品”,在这里可以形象的理解成“不是文件”。

参考文献:
[1] http://blog.csdn.net/linuxtiger/article/details/7955060 作者: 对象

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值