c文件filea.c:
#include <stdio.h>
void fun1()
{
printf("i am from filea fun1 \n");
}
c文件fileb.c:
#include <stdio.h>
void fun2()
{
printf("i am from fileb fun2 \n");
}
测试文件testso.c
void fun1();
void fun2();
int main(int argc,char *argv[])
{
fun1();
fun2();
return 0;
}
1.将filea.c fileb.c编译成so库供testso.c调用,命令如下:
gcc -Wall -fpic -shared filea.c fileb.c -o first.so
2.编译testso.c并链接共享库first.so
gcc -Wall testso.c first.so -o testso