make clean指令出现问题

今天第一次使用make指令,没搞懂make clean就直接使用了,结果发现如下错误问题:make: *** No rule to make target 'clear'。 停止。

最后的找了半天有下面两个结果:

1:根本在makefile文件当中没有写clean的相关的处理动作,make指令后面的参数就像C语言main函数的传入参数int argv和int **arg那样,对写入的指令进行操作:(应该在Makefile中的末尾应该这样写

clean:

  rm *.o main xxx

详细问题请参考:http://stackoverflow.com/questions/30962134/make-no-rule-to-make-target-rm-needed-by-clean-stop

2:你的makefile的名字命名为makefile.mk的形式,所以这个时候就不能用Make clean指令来完成操作了,而是使用如下的指令:make -f makefile.mk clean。

     当然你最好把makefile.mk的名字改为Makefile,这样就能很方便的清除make之后产生的.o文件以及一些编译过程中产生的中间文件了。

详细问题请参考:http://www.cnblogs.com/mmix2009/p/3191596.html

其他make指令相关的问题或者makefile编写的问题大家参考下面的文章吧!

简洁版:http://www.cnblogs.com/luchen927/archive/2012/02/05/2339002.html

详细版:http://blog.csdn.net/ruglcc/article/details/7814546/

原文地址:https://www.cnblogs.com/uestc-mm/p/6371904.html