linux c 调用 so 库
生活随笔
收集整理的這篇文章主要介紹了
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); }
#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); }
?
轉載于:https://www.cnblogs.com/libing029/p/10482702.html
總結
以上是生活随笔為你收集整理的linux c 调用 so 库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nginx详解五:Nginx基础篇之HT
- 下一篇: 大数据学习——spark安装