请高手指点,关于dlopen的问题

chun4221 2011-11-14 12:39:20
以下为我的程序:

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include "test.h"

int main()
{
char *dll = "/DB2/test/displaydatapath/test/test.so";
void *handle = dlopen(dll,RTLD_NOW);
char *error;
if(!handle)
{
printf("load test.so fail\n");
return -1;
}

printf("load test.so success\n");

typedef int (*input)();
input in;
in = (input)dlsym(handle,"test");

if(!in)
{
error = dlerror();
printf("%s\n",error);
printf("load input test fail\n");
return -1;
}

in();

dlclose(handle);

return 0;
}


输出结果如下 :
load test.so success
Function not implemented (test)
load input test fail

望请教,为什么dlsym 返回值不对??
多谢了
...全文
120 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
chun4221 2011-11-14
  • 打赏
  • 举报
回复
以下为test函数的全部:
#include <stdio.h>
#include <string.h>
#include <global.h>
#include <osfile.h>
#include "test.h"

int test()
{
printf("test func");
char DataDir[256];
char MaileServerName[256];
STATUS error = NOERROR;
int wlength=0;
memset(DataDir,0,256);
memset(MaileServerName,0,256);
printf("notesinit up");
//if (NotesInitExtended(argc,argv))
if(NotesInit())
{
printf("\n Unable to initialize Notes.\n");
return (1);
}
printf("init success");
wlength = OSGetDataDirectory(DataDir);
//SECKFMGetUserName(MaileServerName);
if (wlength > 0)
printf("\n The data directory is %s\n", DataDir);
//printf("\n The domino Server name is %s\n",MaileServerName);

NotesTerm();
return 0;
}
~
~
chun4221 2011-11-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xiakan008 的回复:]
发一下test函数~是不是最后有个;号啊
把;删掉重新编译下 再试下~!
[/Quote]

删除哪里的“;”符号啊?我看的不是太懂
chun4221 2011-11-14
  • 打赏
  • 举报
回复

int test();
BT六眼飞鱼 2011-11-14
  • 打赏
  • 举报
回复
发一下test函数~是不是最后有个;号啊
把;删掉重新编译下 再试下~!

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧