#include <link.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//#include <dlfcn.h>
void getSOPath(void *fun)
{
char *pDest;
Dl_info dlinfo;
int ret=0;
ret = dladdr(fun,&dlinfo);
if(!ret)
{
g_szDllPath[0]='\0' ;
}
else
{
strncpy(g_szDllPath, dlinfo.dli_fname,_MAX_PATH);
pDest = strrchr(g_szDllPath, '/');
if(pDest != NULL)
pDest[1] = '\0';
else
{
pDest = strrchr(g_szDllPath, '\\');
if(pDest != NULL)
{
pDest[1] = '\0';
}
else
{
memcpy(g_szDllPath,"./",sizeof("./"));
}
}
}
}
linux 下获得so的路径
最新推荐文章于 2024-05-07 14:20:07 发布