当前位置: 技术问答>linux和unix
关于makefile中的一个问题
来源: 互联网 发布时间:2016-07-13
本文导语: 问一个关于Makefile的问题 main:main.o test.o test2.o gcc main.o test.o -o main main.o:main.c test.h gcc -c main.c -o main.o test.o:test.c test.h gcc -c test.c -o test.o 在这里,test.c和main.c在不同的文件夹下面,比如test.c在./test下...
问一个关于Makefile的问题
main:main.o test.o test2.o
gcc main.o test.o -o main
main.o:main.c test.h
gcc -c main.c -o main.o
test.o:test.c test.h
gcc -c test.c -o test.o
在这里,test.c和main.c在不同的文件夹下面,比如test.c在./test下,而main.c在./main文件下,那么这里的makefile中该怎么写呢
main:main.o test.o test2.o
gcc main.o test.o -o main
main.o:main.c test.h
gcc -c main.c -o main.o
test.o:test.c test.h
gcc -c test.c -o test.o
在这里,test.c和main.c在不同的文件夹下面,比如test.c在./test下,而main.c在./main文件下,那么这里的makefile中该怎么写呢
|
加路径啊,觉得不好看就用环境变量表示。
|
定义一个路径就可以了,只要最终的.o文件能够找到就行
|
定义一个include filename
执行make -I 会自己在include目录下搜索
执行make -I 会自己在include目录下搜索
|
gcc -I filename_path
就行了!
就行了!
|
linux?