Link error Zlibstat.lib, VS 2010, zlib 1.2.8

I am trying to use zlibstat.lib generated by the build solution zlib-1.2.8 \ contrib \ vstudio \ vc10 \ zlibvc.sln

He created zlibstat.lib, but when I link it to another project, I get the following errors:

  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 ....

I used dumpbin to list the characters from this 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

64:

  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

If you add zlib code to my project, it works great.

What am I doing wrong when I try to link it to a library? I am using a 64 bit machine and the configuration platform is win32. I tried using x64 but did not work.

+4
source share
1 answer

For everyone who comes across this question: I just decided this a few minutes ago, and personally I think that this is a small mistake in 1.2.8 sources. Release 1.2.8 contains the VS2010 project for creating zlibstat.lib, and, as expected, the static library file specified with the name is defined by the ZLIB_WINAPI macro, which creates a dynamically linked lib file.

So, without further ado: compile zlibstat.lib in VS2010 : Just go to projects, go to C/C++ → Preprocessor and remove the ZLIB_WINAPI macro from Preprocessor Definitions

+1
source

Source: https://habr.com/ru/post/1496537/


All Articles