linux c 调用 so 库

/***********编译时要链接 -l dl 库************/

#include<stdlib.h> #include<stdio.h> #include<unistd.h> #include"person.h" #include<memory.h> #include<string.h> #include<dlfcn.h> int main(){ typedef int (*SELECT)(PERSON*); typedef void (*ADD)(int ,PERSON*); void *handle; if((handle=dlopen("./libper.so",RTLD_LAZY/*RTLD_NOW*/))==NULL){ printf("load so fail"); } ADD add=(ADD)dlsym(handle,"addperson"); dlclose(handle); }

猜你喜欢

转载自www.cnblogs.com/libing029/p/10482702.html
今日推荐