专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > C语言

怎么在VS2008建立一个DLL工程,这个工程还必须引用其它dll中的函数

发布时间:2011-06-28 13:37:01 文章来源:www.iduyao.cn 采编人员:星星草
如何在VS2008建立一个DLL工程,这个工程还必须引用其它dll中的函数
我使用动态库封装redis的访问,但是windows下的redis安装包里只提供了libhiredis.dll,封装了诸如:
  1 0 00003B70 __redisAppendCommand
  2 1 00003288 __redisSetError
  3 2 0000BC68 _get_output_format
  4 3 00001794 freeReplyObject
  5 4 00003BEC redisAppendCommand
  6 5 00003C3C redisAppendCommandArgv
  7 6 000065A0 redisAsyncCommand
  8 7 000065EC redisAsyncCommandArgv
  9 8 00005C68 redisAsyncConnect
  10 9 00005D78 redisAsyncConnectUnix
..........

我需要引用上述函数,该如何在自己的dll工程中加入libhiredis.dll?谢谢。
我的dll工程里的.c文件没有dllmain函数,只是建立了各种封装函数,并在.h文件里声明了:

extern int connectDB(const char* ip, int port, const char* userid, const char* pwd);
extern int disconnectDB();
.......

编译错误是:
1>Linking...
1>libapmsclient.obj : error LNK2019: unresolved external symbol _freeReplyObject referenced in function _connectDB
1>libapmsclient.obj : error LNK2019: unresolved external symbol _redisCommand referenced in function _connectDB
1>libapmsclient.obj : error LNK2019: unresolved external symbol _redisConnectWithTimeout referenced in function _connectDB
1>libapmsclient.obj : error LNK2019: unresolved external symbol _redisFree referenced in function _disconnectDB
1>libapmsclient.obj : error LNK2019: unresolved external symbol _snprintf referenced in function _getStatistics
1>E:\WorkGroup\Win32\libapmsclient\libapmsclient\Debug\libapmsclient.dll : fatal error LNK1120: 5 unresolved externals

请高人指点,希望能详细一点。


------解决方案--------------------
链接时加入那个dll的导入库
------解决方案--------------------
先到https://github.com/MSOpenTech/redis下源代码.
把sln文件在vs2010里编译,生成hirdis.lib
在你的工程里直接用hirdis.h和其它你需要的.h文件,
在工程属性 linker里把hirdis.lib加上
------解决方案--------------------
#pragma comment(lib, "hirdis.lib")
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: