【问题标题】:Zlibstat.lib link error, VS 2010, zlib 1.2.8Zlibstat.lib 链接错误,VS 2010,zlib 1.2.8
【发布时间】:2013-08-12 10:25:19
【问题描述】:

我正在尝试使用通过构建解决方案生成的 zlibstat.lib zlib-1.2.8\contrib\vstudio\vc10\zlibvc.sln

它生成了一个 zlibstat.lib,但是当我将它与另一个项目链接时,我收到以下错误:

错误 LNK2001:未解析的外部符号 _compress2 错误 LNK2001:无法解析的外部符号 _uncompress 错误 LNK2019:函数中引用了未解析的外部符号 _compress2... 错误 LNK2019:函数中引用了未解析的外部符号 _crc32 ....

我使用 dumpbin 从这个 zlibstat.lib 中转储符号列表

x86:

00B 00000000 SECT4 notype () 外部 | _uncompress@16 029 000024F0 SECT5 notype () 静态 | _compress_block 00B 00000000 SECT4 notype () 外部 | _compress2@20 00F 000000C0 SECT4 notype () 外部 | _compress@16 010 000000E0 SECT4 notype () 外部 | _compressBound@4

x64:

00A 00000000 SECT4 notype () 外部 |解压缩 00D 00000000 SECT5 notype 静态 | $pdata$解压缩 010 00000000 SECT6 notype 静态 | $unwind$解压缩 050 00002E50 SECT5 notype () 静态 |压缩块 051 000000B4 SECT6 notype 静态 | $pdata$compress_block 052 00000078 SECT7 notype 静态 | $unwind$compress_block 00A 00000000 SECT4 notype () 外部 |压缩2 00D 00000000 SECT5 notype 静态 | $pdata$compress2 010 00000000 SECT6 notype 静态 | $展开$压缩2 015 00000150 SECT4 notype () 外部 |压缩 016 0000000C SECT5 notype 静态 | $pdata$压缩 017 00000008 SECT6 notype 静态 | $展开$压缩 019 000001A0 SECT4 notype () 外部 |压缩绑定

如果将 zlib 的代码添加到我的项目中,它可以正常工作..

尝试将其与库链接时我做错了什么? 我用的是64位机器,配置平台是win32..我试过用x64但是没用..

【问题讨论】:

标签: visual-studio-2010 linker static-libraries zlib


【解决方案1】:

对于遇到此问题的任何人: 几分钟前我自己刚刚解决了这个问题,我个人认为这是 1.2.8 源代码中的一个小错误。 1.2.8 版本包含一个用于构建 zlibstat.lib 的 VS2010 项目,尽管人们会期望一个静态库文件的名称,但定义了宏 ZLIB_WINAPI,它会生成一个动态链接的 lib 文件。

所以事不宜迟:编译 VS2010 中的 zlibstat.lib: 只需转到项目的属性,转到C/C++->Preprocessor 并从Preprocessor Definitions 中删除ZLIB_WINAPI 宏

【讨论】:

  • 谢谢!我对 zlib 1.2.11 和它附带的 VS2015 项目(vc14)有同样的问题,这解决了它。我想知道为什么 zlib 项目是这样设置的?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多