1、首先是创建三个文件 test_1.c test_2.c test_3.c
test_1.c
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("Holle World 1111111111 \n");
linkme2();
}工具
test_2.c源码
#include <stdio.h>
#include <stdlib.h>
int linkme2(void){
printf("Holle World 222222222222222\n");
linkme3();
}io
test_3.c
#include <stdio.h>
#include <stdlib.h>
int linkme3(void){
printf("Holle World 333333333333\n");
}编译
2、进行编译
gcc -o test test_1.c test_2.c test_3.ctest
3、直接运行,能够直接看到效果
./testgcc
makefile 的制做方法:file
一、了解makefile的语法
创建makefile,而且加入一下的内容
main:test_1.o test_2.o test_3.o
<tab>gcc -o test test_1.o test_2.o test_3.o
clean:
<tab>rm -rf test_1.o test_2.o test_3.o
二、make #注意这里 make实际上是gun下的一个工具,在加入了以后会自动的将.c的文件进行gcc的操做,具体的效果以下:
cc -c -o test_1.o test_1.c
cc -c -o test_2.o test_2.c
cc -c -o test_3.o test_3.c
gcc -o test test_1.o test_2.o test_3.o
三、make clean #将生成的编译文件给自动的删除掉
rm -rf test_1.o test_2.o test_3.o语法
四、make clean test #进行检测 源码是否有变化
rm -rf test_1.o test_2.o test_3.o
make: Nothing to be done for `test'.
gc