假如我想把以下的代码编译为动态库
/*code.c*/
#include <stdio.h>
void out()
{
printf("::I am a static library");
}
编译生产静态库
#编译并装配 生成.o文件
gcc -c code.c
#归档为静态库文件
ar -r libcode.a code.o
调用静态库编译为可执行文件
#方式一(当做库看待)
gcc app.c -lcode -static -L. -o app
#方式二(当做装配好的.o文件看待)
gcc app.c libcode.a -L. -o app
./app
call library==>::I am a static library