您的位置:首页 > 其它

**没有规则可以创建“XXX”需要的目标“XXX”问题的解决方案

2015-03-31 16:23 337 查看
原文摘自:http://m.blog.csdn.net/blog/hailin0716/17956573#

该博文参考:snowboy.blog.chinaunix.net,感谢这位博主讲解。

一、现象

我将之前Redhat9.0编译好的uboot,转到ubuntu12.04环境。在ubuntu环境下对 uboot重新编译提示错误。编译过程如下:

root@hailin-virtual-machine:/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06#
make clean

root@hailin-virtual-machine:/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06# make TX2440_config

Configuring for TX2440 board...

root@hailin-virtual-machine:/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06# make -j4

Generating include/autoconf.mk

Generating include/autoconf.mk.dep

for dir in tools examples/standalone examples/api arch/arm/cpu/arm920t /home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/arch/arm/cpu/arm920t/ ; do \

make -C $dir _depend ; done

make[1]: 正在进入目录 `/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/tools'

make[1]: 没有什么可以做的为 `_depend'。

make[1]:正在离开目录 `/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/tools'

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。此处省略部分编译输出

make[1]: 正在进入目录 `/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/tools'

make[1]:*** 没有规则可以创建“crc32.o”需要的目标“/home/hailin/u-boot-2010.06/lib/crc32.c”。 停止。

make[1]:正在离开目录 `/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/tools'

make: *** [tools] 错误 2

make: *** 正在等待未完成的任务....

make[1]: 正在进入目录 `/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/examples/standalone'

make[1]:*** 没有规则可以创建“hello_world.o”需要的目标“/home/hailin/u-boot-2010.06/include/common.h”。
停止。

make[1]:正在离开目录 `/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06/examples/standalone'

make: *** [examples/standalone] 错误 2

make: *** wait: 没有子进程。 停止。

root@hailin-virtual-machine:/home/hailin/桌面/dream/tx2440/uboot/u-boot-2010.06#

为什么之前在redhat环境中,可以成功编译,而到ubuntu环境会出现没有规则呢??

二、解决方法

输入以下命令:

make disclean

make TX2440_config

make -j4

输出结果:

为什么
将make clean 换成 make distclean就成功???


三、原理

首先我们不得不提到:make
clean 和make distclean的区别:

make clean仅仅是清除之前编译的可执行文件及配置文件。

而make distclean要清除所有生成的文件

make distclean类似make clean,但同时也将configure生成的文件全部删除掉,包括Makefile。

从上面的解析可以看出,上面的问题的根源是因为,从redhat拿来uboot代码里面已经有配置文件,是根据原来的编译环境生成的,仅仅通过make clean并不能清楚之前的配置文件,没有清除之前的配置文件就进行编译,编译器本着相信程序员的态度,编译时不会产生新的configure生成的附带文件,而是根据原来的configure生成的文件进行编译,这样就会导致上面的一系列编译错误。make
distclean可以将所有的垃圾,之前环境所有的余孽清理干净,这样就不会给编译器偷懒的机会。

综上所述:拿到任意个uboot、kernel源码,都要做一次 make distclean,清除所有生成文件。避免上述的低级错误的出现。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐