例如:
/home/files文件夹下有文件main.c:
/home/files/common文件夹下有文件tou.h和shixian.c。
tou.h为:
若有多个shixian文件,比如shixian1.c, shixian2.c,都可以在tou.h中用extern声明出来。
shixian.c为:
编译时用命令:gcc main.c ./common/shixian.c -o main -I /home/files/common
其中,-I /home/files/common代表链接到头文件所在目录。若.h文件都在本目录下,则不用加-I指明.h文件所在文件夹。
另外,-lm表示链接到数学函数库。