- 论坛徽章:
- 0
|
主函数main
#include <stdio.h>;
#include <errno.h>;
#include <dlfcn.h>;
main () {
char (* myFun)();
char * handle;
(void *)handle = dlopen("./libfuncso.so", RTLD_LAZY);
printf("error == [%d]\n",errno);
if(handle == NULL)
{
printf("dlopen = [%d] [%s]\n",errno,dlerror());
return ;
}
(void *)myFun = (void(*)(int))dlsym(handle,"funcso" ;
if (myFun == NULL)
{
printf("dlsym = [%d] [%s]\n",errno,dlerror());
dlerror();
return ;
}
if(dlclose(handle))
{
printf("dlclose = [%d] [%s]\n",errno,dlerror());
return ;
}
return 0;
}
辅助函数:funcso.c
#include <stdio.h>;
#include <string.h>;
#include <stdlib.h>;
int funcso(){
fprintf(stdout,"Where is funcso?!\n" ;
return 0;
}
将funcso.c编译生成libfuncso.so
然后编译main生成main。运行后,显示:
¥ error == [109]
¥
为什麽是这种结果,请大侠给予解答! 运行环境AIX4,3 |
|