在同一个进程中多次dlopen同一个so库,返回的句柄值是一样的
共享库例子代码(hell.c):
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int g_count = 0;
int add_count()
{
g_count +=1;
char buff[64] = {0};
int fd;
fd = open("so.txt", O_RDWR | O_APPEND);
// printf("g_count= %d\r\n", g_count);
sprintf(buff, "g_count= %d\r\n", g_count);
write(fd, buff, 64);
sync();
sleep(1);
return g_count;
}
APP1例子代码(app1.c)
#include <stdio.h>
#include <dlfcn.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
void *handle;
int (*fun_han)();