编译器
GCC编译
gcc -o hello.o hello.c
交叉编译器编译
arm-linux-gnueabihf-gcc -o hello hello.c
编译过程:预处理,编译,汇编,链接
-E:预处理
-S:汇编
-c:编译
-i -L:链接
-o file:指定输出文件
hello.c -> hello.i
hello.i -> hello.s
hello.s -> hello.o
hello.o -> hello(a.out)
gcc -E hello.c -o hello.i
gcc -S hello.i
gcc -c hello.s
gcc hello.o
头文件包含
#include <head.h>
//预处理器搜索系统预设目录
#include "head.h"
//预处理器搜索目标文件目录,然后再搜索系统预设目录。
链接库文件
gcc hello.c libFOO.a
//链接静态库
gcc hello.c libFOO.so
//链接动态库
gcc hello.c -L /home/vmuser/hello
//-L 指定库文件路径
gcc hello.c -L /home/vmuser/hello -lFOO
//-L 指定库文件路径 -l指定库文件