靜態庫
xxx.a
動態庫
xxx.so
例子
ku.c
#include <stdio.h>
int helloku(void)
{
printf("hello ku\r\n");
return 0;
}
ku.h
#ifndef __KU__
#define __KU__
int helloku(void);
#endif
gcc -c ku.c生成ku.o
編譯生成靜態庫
ar crv libku.a ku.o
test.c
#inckude "ku.h"
int main(void)
{
helloku();
return 0;
}
gcc test.c -o test -L./ -lku
編譯生成動態庫
gcc -shared -fPCI -o libku.so ku.o
gcc test.c -o test -L./ -lku
注意:要將libku.so放到 /usr/lib下面