準備三個檔案test.h, test.c, main.c
test.h
#include <stdio.h>
void say_hello();
test.c
#include "test.h"
void say_hello(char *name){
printf("hello %s\n", name);
}
main.c
#include "test.h"
int main(){
say_hello("guanxianseng");
return 0;
}
執行生成so檔案指令
gcc test.c -fPIC -shared -o libtest.so
gcc main.c -L. -ltest -o main