makefile简单实例 |
假设我们有一个程序由5个文件组成,源代码如下: /*main.c*/ #include "mytool1.h" #include "mytool2.h" int main() { mytool1_print("hello mytool1!"); mytool2_print("hello mytool2!"); return0; } /*mytool1.c*/ #include "mytool1.h" #include <stdio.h> void mytool1_print(char*print_str) { printf("This is mytool1 print : %s\n",print_str); } /*mytool1.h*/ #ifndef _MYTOOL_1_H #define _MYTOOL_1_H void mytool1_print(char*print_str); #endif /*mytool2.c*/ #include "mytool2.h" #include <stdio.h> void mytool2_print(char*print_str) { printf("This is mytool2 print : %s\n",print_str); } /*mytool2.h*/ #ifndef _MYTOOL_2_H #define _MYTOOL_2_H void mytool2_print(char*print_str); #endif 首先了解一下make和Makefile.GNU make是一个工程管理器,它可以管理较多的文件 |