Makefile执行过程中出错:make: *** No rule to make target ` ‘, needed by xxx. Stop.

【问题】

有个已有的Makefile,执行过程中出错:

CLi@PC-CLI-1 ~/develop/docbook/books/python_topic_str_encoding/src
$ make html
=============================== cleaning html ==============================
rm -rf ../output/html/single/*
make: *** No rule to make target ` ‘, needed by `../output/html/single/python_topic_str_encoding.html’.  Stop.

 

【解决过程】

1.换到别的,和当前文件夹等价的路径中去执行,结果却是正常的:

CLi@PC-CLI-1 ~/develop/docbook/books/python_topic_str_encoding/src
$ cd ../../python_topic_web_scrape/src

CLi@PC-CLI-1 ~/develop/docbook/books/python_topic_web_scrape/src
$ make html
=============================== cleaning html ==============================
rm -rf ../output/html/single/*
=============================== generating html ==============================
export XML_CATALOG_FILES="/home/develop/docbook/config_root/catalog/catalog.xml" && \
export XML_DEBUG_CATALOG=1 && \

……

 

2.后来折腾半天,最后终于发现,原来是由于,当前Makefile中的内容是:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# also means main source file name
PROJECT_NAME = python_topic_str_encoding
SUB_SRC_FILES = \
     python_topic_str_encoding.xml \
     preface.xml \
     ch01_2x_vs_3x.xml \
     ch02_common_encoding_error.xml \
     ch03_other_common_case.xml \
     reference.xml \   
 
DOCBOOK_MAKEFILE_ROOT = ../../.. /config
################################################################################
# Include docbook makefile
################################################################################
include $(DOCBOOK_MAKEFILE_ROOT) /docbook .mk

其中,注意到,所依赖的

reference.xml \

后面还有几个空格的,截图才能看出来:

xml follow with space

导致了此错误。

把最后的,多余的空格去掉:

removed unuseful space

就可以消除此问题了。

 

【总结】

Makefile在编译执行过程中,对于所依赖的条件,此处即一堆xml文件,最后一个是reference.xml,结果由于最后reference.xml后面,有多余的4个空格,导致Makefile将该处的4个空格,视为一个文件了,所以,必然找不到该“文件”,所以才报错的。

所以,如果Makefile出现:

make: *** No rule to make target ` ‘, needed by xxx. Stop.

的错误,那么基本上都是属于找不到所依赖的文件所导致的,所以应该去:

检测确保,所依赖的文件,是否真实存在。

很可能,很常见的一个现象就是,此处的,误写了多余的空格,导致被视为依赖文件,导致找不到,导致报此错误。

解决办法就很简单,去掉多余的空格即可
  • 8
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值