首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

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

2012-08-09 
如何在VS2008建立一个DLL工程,这个工程还必须引用其它dll中的函数我使用动态库封装redis的访问,但是window

如何在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")

热点排行