Makefile第四讲:include 引用其它makefile文件
2015-11-07 16:57
375 查看
main.cpp
#include "classes/fun.h" int main() { Test::display("Hello makefile"); return 0; }
classes/fun.h
#include <iostream> using namespace std; class Test { public: void static display(const char *); };
classes/fun.cpp
#include "fun.h" void Test::display(const char *str) { cout <<str <<endl; }
classes/makefile
test.o:classes/fun.cpp g++ -c classes/fun.cpp -o test.o
makefile
test: test.o main.o g++ test.o main.o -o test main.o:main.cpp g++ -c main.cpp -o main.o include classes/makefile clean: rm main.o test.o test
include classes/makefile
中的include关键字就是引用其它的makefile,值得注意的是,在被引用的makefile文件中的代码,它的路径是相对于引用的makefile文件的路径(注意到test.o:classes/fun.cpp
),思考一下:我可以把include classes/makefile
这句写在开头吗?答案当然是不能,至于为什么,在Makefile第一讲:一个简单的Makefile找
相关文章推荐
- 除以路径中所有数 时间戳+LCA+路径压缩 2D
- 写一个函数排序整个字符串数组
- webservice生成客户端代码时,出现的问题
- 技术人员为什么要写博客
- Makefile第三讲:终端传值给Makefile、Makefile传值给C++代码
- ssh安全配置
- NOIP2015_day1
- trouble shooting
- PowerShell实战 第二回 管理AD用户对象
- Makefile第二讲:打印出内容和使用变量
- Makefile第一讲:一个简单的Makefile
- Visual C++ 64bit应用程序项目设置
- Xpath语法介绍及Web网页元素属性查找
- 最大公约数与最小公倍数
- python之函数用法iter()
- Hibernate与MyBatis
- xss漏洞的常识(摘抄)
- C++拷贝构造函数详解
- POJ 1270Following Orders(拓扑+DFS)
- ANT教程之十五 Ant Junit集成