makefile入门
来源:互联网 发布:大数据修炼系统txt 编辑:程序博客网 时间:2024/06/07 05:31
linux下编程,makefile的重要性不用多说,网上一大堆,今天简单的实战一下。
[xxx@localhost test]$ lsmakefile test1.cpp test2.cpp[xxx@localhost test]$ cat test1.cpp #include<stdio.h>int main(){ printf("this is test1\n"); return 0;}[xxx@localhost test]$ cat test2.cpp #include<stdio.h>int main(){ printf("this is test2\n"); return 0;}[xxx@localhost test]$ cat makefile all:test1 test2test1:test1.o g++ test1.o -o test1test2:test2.og++ test2.o -o test2test1.o:test1.cppg++ -c test1.cpp -o test1.otest2.o:test2.cppg++ -c test2.cpp -o test2.oclean:rm -fr *.o [xxx@localhost test]$
执行:
[xxx@localhost test]$ makeg++ -c test1.cpp -o test1.og++ test1.o -o test1g++ -c test2.cpp -o test2.og++ test2.o -o test2[xxx@localhost test]$ lsmakefile test1 test1.cpp test1.o test2 test2.cpp test2.o[xxx@localhost test]$ ./test1this is test1[mapan@localhost test]$ ./test2this is test2[xxx@localhost test]$all作用:makefile会把第一个目标作为默认,all可以指定多个目标
test.o:test.cpp这表示依赖关系,标明生成test.o需要test.cpp
[mapan@localhost test]$ make clean rm -fr *.omake clean清除所有.o文件
阅读全文
0 0
- makefile入门
- makefile入门
- makefile入门
- makefile入门
- makefile入门
- MakeFile 入门
- Makefile 入门
- Makefile 入门
- makefile入门
- makefile 入门
- makefile入门
- Makefile入门
- makefile入门
- Makefile入门
- Makefile 入门
- Makefile入门
- Makefile入门
- makefile入门
- c# Console.WriteLine() Console.ReadLine()
- aop源码解析二:postProcessBeforeInstantiation
- hibernate的get,load,persist方法比较(二)
- MySQL远程连接提示Accesss denied for user 'root'@'此处为你自己的ip'(using password:YES)
- 数据结构-排序
- makefile入门
- word2016与mathtype6.9的兼容
- dd iso
- 单例
- 递归经典算法 汉诺塔问题
- ceil函数
- 实体类和JSON对象之间相互转化
- linux C总结篇(线程)上
- Hdu-6053 TrickGCD(莫比乌斯函数)