C????????????
???????????? ???????[ 2013/2/26 9:50:48 ] ????????
????????????????????????????????????????????????????ù???? ???????????????????????????ж???? ????????????????????????????????????????????window?н?dll????Unix/Linux?н???so??????????????е?????????е????????Щ??????????dll????so???в?????????????????????ú?????????ú???????????????????????????????????
????????????????????????????????ɡ???????????so????dll??в????????????????Unix/Linux?е?C????????????????????????????dlopen??dlsym?????????е????????dlfcn.h?????С?
void * dlopen( const char * pathname?? int mode);
pathname??so????dll?????·??????Linux?б???????"./"????"../"????????·?? ???? ??"/"?????·??
mode??????so????dll??????????????????? <DIV class=para>RTLD_LAZY????dlopen????????????????е?δ???????????н?????????????????Ч?????????????????????????????</DIV><DIV class=para>RTLD_NOW?? ?????dlopen?????????????????δ?????????????????????????dlopen????NULL
<DIV class=para>????????NULL</DIV><DIV class=para>??????????????</DIV>.</DIV>
dlsym(void *dp?? char * funtionname);
dp:???????so????dll??????
functionname????????????????
?????????void*???????????
dlclose(void *dp)
????????????????????е?????????????ü????0??????????????ж???
??????????
#include <stdio.h>
#include <dlfcn.h>
#include "dll.h"
int main(){
void *dp;
char *err;
char fname[20];
dll p;
void (*init)(dll *p);
pirntf("????????????????????model1 ????model2");
scanf("%s"?? fname);
sprintf("./%s^?? fname);
dp = dlopen(fname?? RTLD_LAZY);//???????
if( NULL == dp) {
printf("%s
"?? dlerror());
exit(1);
}
init = dlsym(dp?? "init");//???init??????????
init(&p);
printf("%s
"?? p.name);
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11