当前位置: 技术问答>linux和unix
请问怎样使用动态连接库?unix/c
来源: 互联网 发布时间:2014-12-30
本文导语: 那位大虾可以提供相关资料?谢谢! | 给你一段我的动态链接库调用代码,比较容易的 typedef int (*RouteDllFunc)(char *buffer,int len,char *arg2,char *arg3); if((DllHandle = dlopen(LibName,RTLD_LAZY)) == NULL) { ...
那位大虾可以提供相关资料?谢谢!
|
给你一段我的动态链接库调用代码,比较容易的
typedef int (*RouteDllFunc)(char *buffer,int len,char *arg2,char *arg3);
if((DllHandle = dlopen(LibName,RTLD_LAZY)) == NULL)
{
fprintf(stderr,"dlopen Errorsn");
}
DllFunc = (RouteDllFunc)dlsym(DllHandle,route->sCommArg1);
if((pError = dlerror()) != NULL)
{
fprintf(stderr,"dlsym error");
return(-1);
}
if((iLen = DllFunc(buffer,len,route->sCommArg2,route->sCommArg3)) == -1)
{
fprintf(stderr, "dllrunc error");
}
typedef int (*RouteDllFunc)(char *buffer,int len,char *arg2,char *arg3);
if((DllHandle = dlopen(LibName,RTLD_LAZY)) == NULL)
{
fprintf(stderr,"dlopen Errorsn");
}
DllFunc = (RouteDllFunc)dlsym(DllHandle,route->sCommArg1);
if((pError = dlerror()) != NULL)
{
fprintf(stderr,"dlsym error");
return(-1);
}
if((iLen = DllFunc(buffer,len,route->sCommArg2,route->sCommArg3)) == -1)
{
fprintf(stderr, "dllrunc error");
}