Avoiding ``No rule to make target ...'' Errors
2010-09-16 11:19
537 查看
在GNU make手册4.14节 给出一种基本的自动生成依赖关系的rules
使用 -MP 选项
from gcc manual
This option instructs CPP to add a phony target for each dependency other than the main file, causing each to depend on nothing. These dummy rules
work around errors make gives if you remove header files without updating the Makefile to match.
This is typical output:
test.o: test.c test.h
test.h:
%.d: %.c @set -e; rm -f $@; / $(CC) -M $(CPPFLAGS) $< > $@.$$$$; / sed 's,/($*/)/.o[ :]*,/1.o $@ : ,g' < $@.$$$$ > $@; / rm -f $@.$$$$
大部分情况下这个都是可以工作的,但是这个仍然有很多的局限,GNU Make的作者Paul Smith在自己的网站上对这个问题进行了详细的阐述,其中一个比较严重的问题
就是 当依赖的头文件由于不再使用被删除,此时在依赖性文件中依然存在对这个文件的依赖,当你make的时候,就会出现No rule to make target ...'' Errors
解决方法据我所知道的有两种
Paul在自己网站上的通过sed对这个依赖性文件在操作,使得每个prerequisites变成target,这样即使依赖的头文件被
删除了,也不会有问题,请参见http://mad-scientist.net/make/autodep.html#advanced
使用 -MP 选项
from gcc manual
This option instructs CPP to add a phony target for each dependency other than the main file, causing each to depend on nothing. These dummy rules
work around errors make gives if you remove header files without updating the Makefile to match.
This is typical output:
test.o: test.c test.h
test.h:
相关文章推荐
- Makefile常见错误解析 - make: *** No rule to make target 'test1.o', needed by 'test2'. Stop
- make: *** No rule to make target `clean'(archive). Stop.
- Android5.0编译问题:No rule to make target 'external/chromium_org/third_party/angle/.git/index',
- 编译内核是出现No rule to make target `firmware/sd8686_helper.bin', 错误的解决
- Openwrt编译python3时出现错误:No rule to make target `package//host/compile'
- 安装ruby2.1.2,openssl时,No rule to make target `/thread_native.h'
- 编译Coco2d-x android 程序出现make: *** No rule to make target ...CCConfiguration.o'. Stop.
- 解决*** No rule to make target `pbk_app.obj',
- error: No rule to make target `c:/Users/Administrator/Desktop/LED_mainWindow/pcb_view.ui', needed by
- 编译Linux内核时的错误 ——make ***No rule to make target 'uimage' .stop
- Nios II编译出错:make: *** No rule to make target `e:/nios ', needed by `/cygdrive/e/nios/Debug/system_de
- android5.0编译问题:No rule to make target 'external/chromium_org/third_party/angle/.git/index',
- android ndk make: * No rule to make target '/', needed by '/android/workspace/NDKTest/obj/解决办法
- 解决No “rule to make target `../Database/images/login.png', needed by `debug/qrc_image.cpp'. Stop.”
- linux内核编译中的各种问题:No rule to make target `menuconfig'&&Unable to find the Ncurses libraries
- No rule to make target `out/target/product/generic/obj/lib/liblog.so'
- No rule to make target 'usr/lib/x86_64-linux-gnu/libcuda.so' Linux下安装OpenCV时 make编译出现的Bug
- 编译 Ceph 的时候报错:No rule to make target `erasure-code/jerasure/jerasure/src/cauchy.c', 如何解决
- android5.0编译问题:No rule to make target 'external/chromium_org/third_party/angle/.git/index',
- “make clean” results in “No rule to make target `clean'”