静态库
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下面
时间: 2025-01-07 14:57:32