2013-08-12 81 views
4

我試圖使用zlibstat.lib在 的zlib-1.2.8 \的contrib \ vstudio \ VC10 \ zlibvc.slnZlibstat.lib鏈接錯誤,VS 2010的zlib 1.2.8

建設的解決方案產生它產生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

86傾倒符號列表:

 
00B 00000000 SECT4 notype() External  | [email protected] 
029 000024F0 SECT5 notype() Static  | _compress_block 
00B 00000000 SECT4 notype() External  | [email protected] 
00F 000000C0 SECT4 notype() External  | [email protected] 
010 000000E0 SECT4 notype() External  | [email protected] 

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 

如果zlib的的代碼添加到我的項目,它工作正常..

什麼我做錯了試圖將其與庫鏈接時? 我使用的64位機和配置平臺是Win32 ..我嘗試使用64位,但沒有工作..

+0

可能重複刪除ZLIB_WINAPI宏:HTTP://計算器.com/questions/5424549/unresolved-externals-though-linking-in-zlib-lib – cen

回答

1

對於任何人碰到這個問題來了: 我剛剛解決了這個自己分鐘前,我個人認爲這是1.2.8源代碼中的一個小錯誤。 1.2.8版本包含一個用於構建zlibstat.lib的VS2010項目,並且其中一個可以期望給定名稱的靜態庫文件,定義了生成動態鏈接的lib文件的宏ZLIB_WINAPI。

因此,事不宜遲:編譯zlibstat.lib在VS2010: 只要進入該項目的proprerties,去C/C++ - >PreprocessorPreprocessor Definitions

+0

謝謝!我遇到了zlib 1.2.11和它自帶的VS2015項目(vc14)的問題,並解決了這個問題。我想知道爲什麼zlib項目是這樣設置的? –