dll中导出函数的问题

shepchencal 2007-07-02 02:38:45
在测试工程中,调用了DLL,代码如下,在CPP文件内加入
#pragma comment(lib,"test.lib")
int initComm();
int send();
编译通过,调用函数正常

但是想要使用带参数函数,int send(int x);
编译时就出错,
SharedDllCallDlg.obj : error LNK2001: unresolved external symbol "int __cdecl send(int)" (?send@@YAHH@Z)

该怎样使用带参数的函数??
谢谢
...全文
321 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
WindRand 2007-07-02
  • 打赏
  • 举报
回复
我觉得你还是用头文件来规范一下好了,如下:
#ifdef __cplusplus
extern "C" {
#endif

int initComm();
int send(int x);

#ifdef __cplusplus
}
#endif
shepchencal 2007-07-02
  • 打赏
  • 举报
回复
代码如下
“DllCallDlg.cpp”
加入
#pragma comment(lib,"tsss.lib")
int initComm();
int send(int x);

void CDllCallDlg::OnCalldllButton()
{
if(initComm()!=1)
MessageBox("初始化端口失败");
send(1);
}

DLL工程中
函数
int initComm()
{
......
......
}
int send(int x)
{
.......
}

.def文件中
EXPORTS
; Explicit exports can go here
initComm
send

不知道在DLL工程中的DLL函数这样写有没有不对
shepchencal 2007-07-02
  • 打赏
  • 举报
回复
胡乱搞了几下又编译通过了,代码一点都没有变,奇怪~~~~
  • 打赏
  • 举报
回复
你的lib文件是怎么导出的?
C还是CPP ?
  • 打赏
  • 举报
回复
extern "C"{
int initComm();
int send();
}试试看

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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