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

该博文参考: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,清除所有生成文件。避免上述的低级错误的出现。


  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值