65,211
社区成员
发帖
与我相关
我的任务
分享
void func(void)
{
static int inited = 0;
if(!inited)
{
do_init();
inited = 1;
}
}
void ref1_func(void)
{
func();
}
void ref2_func(void)
{
func();
}
int main(int argc,char**argv)
{
ref1_func();
ref2_func();
return 0;
}
int main(int argc,char**argv)
{
void* handle1,*handle2;
void (*ref1_func)(void);
void (*ref2_func)(void);
handle1 = dlopen("libref1.so",RTLD_LAZY);
ref1_func = dlsym(handle1,"ref1_func");
handle2 = dlopen("libref2.so",RTLD_LAZY);
ref2_func = dlsym(handle2,"ref2_func");
ref1_func();
ref2_func();
dlclose(handle1);dlopen(handle2)
return 0;
}