经过长时间学习和研究 linux GNU make 工程管理器 ,现在把学习心得与大家分享一下,希望本文能教会您一些有用的东西。 make 工具,是所有想在 Linux/Unix 系统上编程的用户都需要且必须掌握的工具。如果您写的程序没有用到 make 工具,则说明您写的程序仅仅是个人练习小程序,称不上有实用价值的程序,因此我们必须学习、掌握并灵活运用它。 在 Linux/UNIX 系统中,习惯使用 Makefile 或 makfile 文件作为 make 命令目标文件。 Make工具最主要也是最基本的功能就是通过 makefile 文件来描述源程序之间的相互依赖关系并自动维护编译工作。而 makefile 文件需要按照某种语法进行编写,文件中需要说明如何编译各个源文件并连接生成可执行文件,并要求定义源文件之间的依赖关系。 一、多文件编译的总体结构 如下图所示, 本示例 共包含 float 类型加法、加法头函数、int 类型加法、main 主函数、float类型减法、减法头函数、int 类型减法 主函数 view plaincopy to clipboardprint? ·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150 #include "add.h" #include "sub.h" #include int main() { int x, y; float a, b; x=5; y=2; a=5.5; b=2.2; printf("%d + %d = %d\n", x, y, add_int(x, y)); printf("%3.1f + %3.1f = %3.1f\n", a, b, add_float(a, b)); printf("%d - %d = %d\n", x, y, sub_int(x, y)); printf("%3.1f - %3.1f = %3.1f\n", a, b, sub_float(a, b)); return 0; } #include "add.h" #include "sub.h" #include int main() { int x, y; float a, b; x=5; y=2; a=5.5; b=2.2; printf("%d + %d = %d\n", x, y, add_int(x, y)); printf("%3.1f + %3.1f = %3.1f\n", a, b, add_float(a, b)); printf("%d - %d = %d\n", x, y, sub_int(x, y)); printf("%3.1f - %3.1f = %3.1f\n", a, b, sub_float(a, b)); return 0; } 加法头函数 view plaincopy to clipboardprint? ·········10········...