makefile中"-"符号的使用
2016-11-05 23:09
211 查看
在makefile中, -用预告诉make命令忽略当前错误, 继续执行, 我们来简单看下:
这个命令是非常有用的, 我们来看一个例子:
makefile为:
main: main.o g++ -o main main.o main.o: main.cpp g++ -o main.o -c main.cpp clean: rm main *.o执行结果为:
taoge@localhost Desktop> make clean rm main *.o taoge@localhost Desktop> make clean rm main *.o rm: cannot remove `main': No such file or directory rm: cannot remove `*.o': No such file or directory make: *** [clean] Error 1此时, 可以把makefile中的 rm main *.o替换为: -rm main *.o , 它会忽略这些错误。 当然, 在此处, 也可以用rm -f main *.o来处理。
这个命令是非常有用的, 我们来看一个例子:
makefile为:
main: main.o g++ -o main main.o main.o: main.cpp g++ -o main.o -c main.cpp clean: rm main rm 1.o rm 2.o
taoge@localhost Desktop> ls main.cpp makefile taoge@localhost Desktop> touch main 2.o taoge@localhost Desktop> ls 2.o main main.cpp makefile taoge@localhost Desktop> make clean rm main rm 1.o rm: cannot remove `1.o': No such file or directory make: *** [clean] Error 1 taoge@localhost Desktop> ls 2.o main.cpp makefile可见, 前面的rm 1.o失败, 后面的不会执行, 改为:
main: main.o g++ -o main main.o main.o: main.cpp g++ -o main.o -c main.cpp clean: -rm main -rm 1.o -rm 2.o
taoge@localhost Desktop> ls main.cpp makefile taoge@localhost Desktop> touch main 2.o taoge@localhost Desktop> ls 2.o main main.cpp makefile taoge@localhost Desktop> make clean rm main rm 1.o rm: cannot remove `1.o': No such file or directory make: [clean] Error 1 (ignored) rm 2.o taoge@localhost Desktop> ls main.cpp makefile taoge@localhost Desktop>可见, 及时rm 1.o出错, 也会被ignored, 继续往下执行。
相关文章推荐
- Makefile赋值符号的使用——"=" ":=" "?=" "+="
- Makefile赋值符号的使用——"=" ":=" "?=" "+="
- Makefile赋值符号的使用——"=" ":=" "?=" "+="
- 开发日志:使用jquery读取id含./"等特殊符号的对象
- Ubuntu下使用vim编写makefile文件出现错误 "makefile: *** missing separator. stop ."的解决办法
- Regex.Split 在分割 "|" 符号时出现问题,应该使用 "[|]" 才可以分组
- 使用NetCDF库时提示无法链接错误"error LNK2001: 无法解析的外部符号 nc_create"
- makefile文件的使用-"自动化编译"
- linux gdb 没有符号表被读取。请使用 "file" 命令。
- SHELL 数组:数组赋值中符号使用不正确(应该严格按"()"赋值),赋值后不能正确求出数组的长度。
- 使用Xcode阅读Makefile管理的C/C++项目源码(支持调试,符号跳转,自动补全)
- linux gdb 没有符号表被读取。请使用 "file" 命令。
- codeblock无法进行调试,没有符号表被读取。请使用 "file" 命令。
- linux 下 gdb没有符号表被读取。请使用"file" 命令
- 使用log4cplus时遇到的链接错误:无法解析的外部符号 "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,
- C语言中结构体中符号“->”和"."的使用疑惑
- 使用log4cplus时遇到的链接错误:无法解析的外部符号 "public: __thiscall log4cplus::RollingFileAppender::RollingFileAppende
- VS2008使用ATLTRACE遇到编译问题:无法解析的外部符号 "class ATL::CTraceCategory
- Excel中"$",这个符号具体怎么使用!
- linux gdb 没有符号表被读取。请使用 "file" 命令。