基础知识
源程序编译
使用 gcc 编译程序
int main(int argc, char** argv)
{
printf("Hello Linux\n");
}
要编译这个程序,执行以下命令
gcc -o hello hello.c
gcc 编译器会为我们生成一个可执行文件 hello。
gcc 参数选项
- -o 表示我们要求编译器为我们输出可执行文件。
- -c 表示我们只要求编译起输出目标代码,而不必输出可执行文件。
- -g 表示我们要求编译器在编译的时候提供对程序的调试信息。
MakeFile 的编写
假设我们有以下几个源文件
/*main.c*/
#include "mytool1.h"
#include "mytool2.h"
int main(int argc, char** argv)
{
mytool1_print("hello");
mytool2_print("hello");
}
/*mytool1.h*/
#