Chinaunix首页 | 论坛 | 博客
  • 博客访问: 790524
  • 博文数量: 10
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 115
  • 用 户 组: 普通用户
  • 注册时间: 2018-12-13 10:14
文章分类

全部博文(10)

文章存档

2020年(1)

2019年(9)

我的朋友

分类: C/C++

2019-11-04 16:22:32

vpath和VPATH,还有g++搜索路径的说明:
https://blog.csdn.net/changli_90/article/details/7881905

makefile变量的使用:
https://blog.csdn.net/naughfy/article/details/80150312

全自动构建的例子:
https://www.cnblogs.com/lzpong/p/9205736.html

简单的makefile使用举例:
文件结构如下:
./
├─./bin
├─./src
│  ├─./utils
│  │    └─testLib.cpp
│  └─main.cpp
├─./include
│  ├─./utils
│     └─testLib.h
├─./obj
└─makefile


创建上面结构的命令:
rm -fr *
mkdir bin
mkdir src
mkdir include
mkdir obj
touch makefile
cd src
mkdir utils
cd utils
touch testLib.cpp
cd ..
touch main.cpp
cd ..
cd include
mkdir utils
cd utils
touch testLib.h
cd ../..




下面是makefile的写法:注意的是foreach的使用,很多地方都可以用foreach来减少makefile的书写
srcPath := ./src
srcPath += ./src/utils


incPath := ./include
incPath += ./include/utils


incPathCpp := -I./include
incPathCpp += -I./include/utils


vpath %.cpp $srcPath
vpath %.h ${incPath}


exeTest:main.o testLib.o
g++ -o $@ $(foreach of, $^,./obj/$(of))


main.o:./src/main.cpp ./include/utils/testLib.h
g++ -c $(incPathCpp)  $< -o ./obj/main.o


testLib.o: ./src/utils/testLib.cpp ./include/utils/testLib.h
g++ -c $(incPathCpp)  $< -o ./obj/testLib.o


rm:
rm obj/*
阅读(267431) | 评论(0) | 转发(0) |
0

上一篇:python字符串

下一篇:DCT

给主人留下些什么吧!~~