make -n(仅列出命令, 但不会执行)用于调试makefile
2016-11-05 22:39
357 查看
我们先来看一个简单程序:
taoge@localhost Desktop> make
g++ -o main.o -c main.cpp
g++ -o main main.o
taoge@localhost Desktop> ls
main main.cpp main.o makefile
taoge@localhost Desktop> make clean
rm -f main *.o
taoge@localhost Desktop> ls
main.cpp makefile
<pre name="code" class="plain">taoge@localhost Desktop>
可以看到, 执行make -n的时候, 并没有生成真正的文件, 因为这知识一个调试命令, 它仅仅列出即将执行的命令, 但不会具体执行命令。 很多时候, 我们调试makefile的时候, 需要用到-n参数。
再来看一下:
#include <iostream> using namespace std; int main() { cout << "hello world" << endl; return 0; }然后来看看makefile:
main: main.o g++ -o main main.o main.o: main.cpp g++ -o main.o -c main.cpp clean: rm -f main *.o看一下执行结果:
taoge@localhost Desktop> make
g++ -o main.o -c main.cpp
g++ -o main main.o
taoge@localhost Desktop> ls
main main.cpp main.o makefile
taoge@localhost Desktop> make clean
rm -f main *.o
taoge@localhost Desktop> ls
main.cpp makefile
<pre name="code" class="plain">taoge@localhost Desktop>
taoge@localhost Desktop>
taoge@localhost Desktop>taoge@localhost Desktop> make -ng++ -o main.o -c main.cppg++ -o main main.otaoge@localhost Desktop> lsmain.cpp makefile
可以看到, 执行make -n的时候, 并没有生成真正的文件, 因为这知识一个调试命令, 它仅仅列出即将执行的命令, 但不会具体执行命令。 很多时候, 我们调试makefile的时候, 需要用到-n参数。
再来看一下:
taoge@localhost Desktop>:~/test> make g++ -o main.o -c main.cpp g++ -o main main.o taoge@localhost Desktop>:~/test> make -n make: `main' is up to date.一目了然。
相关文章推荐
- 使用ant的exec命令来调用 make命令执行makefile文件
- 关于linux下执行脚本编译C++:需要使用make命令和makefile
- makefile 的make命令默认只执行第一条命令
- makefile详解 嵌套执行make,定义命令包 十六
- Vim 执行命令并打印原命令,用于调试
- make -k(keep going)命令会在发现错误时继续执行(用于一次发现所有错误)
- 用于Makefile的make命令参数介绍
- makefile详解 嵌套执行make,定义命令包
- makefile详解 嵌套执行make,定义命令包
- makefile调试2--显示而不执行make
- [makefile 笔记]之一--Make的工作方式、命令执行、伪目标与冒号
- U-boot 编译学习---make TQ2440_config命令执行过程---在 Makefile 中
- 为什么执行make命令时, clean后面的命令不会执行?
- 深入学习Make命令和Makefile
- 深入学习Make命令和Makefile(上)
- 深入学习Make命令和Makefile(下)
- “C语言” 读书札记(六)之[Linux下C语言编程环境Make命令和Makefile]
- 深入学习Make命令和Makefile(下)
- 编译busybox1.16的时候,执行make命令,报错,错误信息:437 “mixed implicit and normal rules”,翻译为中文:混合的和隐含普通规则
- Linux程序设计——make命令与makefile文件