Zlibstat.lib 链接错误,VS 2010,zlib 1.2.8

4
我试图使用在zlib-1.2.8\contrib\vstudio\vc10\zlibvc.sln中构建的zlibstat.lib。它生成了一个zlibstat.lib,但是当我将其与另一个项目链接时,出现以下错误: error LNK2001: unresolved external symbol _compress2 error LNK2001: unresolved external symbol _uncompress error LNK2019: unresolved external symbol _compress2 referenced in function... error LNK2019: unresolved external symbol _crc32 referenced in function ....
我使用dumpbin从zlibstat.lib中转储符号列表: x86:
00B 00000000 SECT4 notype () External | _uncompress@16 029 000024F0 SECT5 notype () Static | _compress_block 00B 00000000 SECT4 notype () External | _compress2@20 00F 000000C0 SECT4 notype () External | _compress@16 010 000000E0 SECT4 notype () External | _compressBound@4
x64:
00A 00000000 SECT4 notype () External | uncompress 00D 00000000 SECT5 notype Static | $pdata$uncompress 010 00000000 SECT6 notype Static | $unwind$uncompress 050 00002E50 SECT5 notype () Static | compress_block 051 000000B4 SECT6 notype Static | $pdata$compress_block 052 00000078 SECT7 notype Static | $unwind$compress_block 00A 00000000 SECT4 notype () External | compress2 00D 00000000 SECT5 notype Static | $pdata$compress2 010 00000000 SECT6 notype Static | $unwind$compress2 015 00000150 SECT4 notype () External | compress 016 0000000C SECT5 notype Static | $pdata$compress 017 00000008 SECT6 notype Static | $unwind$compress 019 000001A0 SECT4 notype () External | compressBound
如果将zlib的代码添加到我的项目中,则可以正常工作。但是,当我尝试将其与库链接时,出现了问题。我正在使用64位计算机,配置平台为win32。我尝试使用x64,但没有成功。请问我做错了什么?

可能重复:https://dev59.com/suo6XIcBkEYKwwoYTSsu - cen
1个回答

1
对于任何遇到这个问题的人: 我刚刚在几分钟前解决了这个问题,我个人认为这是1.2.8源代码中的一个小错误。 1.2.8版本包含一个VS2010项目来构建zlibstat.lib,尽管根据名称应该期望得到静态库文件,但宏ZLIB_WINAPI被定义,这会产生一个动态链接的lib文件。
因此,要在VS2010中编译zlibstat.lib: 只需进入项目属性,转到C/C++->预处理器,并从预处理器定义中删除ZLIB_WINAPI宏即可。

谢谢!我也遇到了zlib 1.2.11和附带它的VS2015项目(vc14)的相同问题,这个解决了它。我想知道为什么zlib项目会被设置成这样? - Michael Geary

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接