Unresolved externals despite linking in zlib.lib

后端 未结 8 1016
礼貌的吻别
礼貌的吻别 2020-12-05 23:25

I\'ve been trying to compile an application which utilizes zlib compression in VC++ 2010.

I get the

error LNK2019: unresolved external symbol _infla         


        
8条回答
  •  天涯浪人
    2020-12-05 23:33

    I ran into the same problem myself using Visual Studio 2017. I got error messages like:

    error LNK2019: unresolved external symbol __imp__deflate referenced in function 
    error LNK2019: unresolved external symbol __imp__deflateEnd referenced in function 
    error LNK2019: unresolved external symbol __imp__inflate referenced in function 
    error LNK2019: unresolved external symbol __imp__inflateEnd referenced in function 
    error LNK2019: unresolved external symbol __imp__deflateInit2_ referenced in function
    error LNK2019: unresolved external symbol __imp__inflateInit2_ referenced in function
    

    I followed the tip from Michael Burr, checking if the zlib file I had contained these methods:

    dumpbin /symbols zlib.lib
    

    The output showed the methods were there, yet Visual Studio still complained. Ultimately I downloaded the latest stable release of zlib from their github repository, and then compiled it (using a Visual Studio Developer Console). Their instructions were not directly helpful though eventually I found their MS Makefile which contained the command I needed to run.

    nmake -f win32/Makefile.msc
    

    Have a look inside their win32/Makefile.msc file for more information on the building process.

    The build process generated two .lib files. What I really needed in my project was the one called 'zdll.lib'. (See their documentation file DLL_FAQ.txt for info on it). Back inside Visual Studio, I had to manually add the file to my project (NOT using the Linker --> General --> Additional Library Directories method, since this triggered the other problems.) You can add them by Right-Clicking on the Solution Object (Not the topmost item in the list, but the second item. In the picture below, my project is called Lasso, so you would want to click on the equivalent in your project.)

    Go to: Add --> Existing Item...

    Then select the generated zdll.lib file.

    Lib files explicitly added to Visual Studio project

提交回复
热议问题