Search code examples
c++visual-studioboostvisual-studio-2015libpng

How to use libpng in Visual Studio?


I am using boost generic image library and it requires libpng. I built libpng and obtained the files libpng.lib, zlib.lib and libpngd.lib. When I tried to compile my project, Visual Studio gives a fatal error

fatal error LNK1120: 21 unresolved externals

with a bunch of unresolved external symbols like _png_set_sig_bytes and _png_read_row. What's going on here and how to solve it?


Solution

  • From MSDN:

    https://msdn.microsoft.com/en-us/library/ba1z7822.aspx?f=255&MSPPError=-2147217396

    To add .lib files as linker input in the development environment
    
        Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
    
        Click the Linker folder.
    
        Click the Input property page.
    
        Modify the Additional Dependencies property.
    

    You must do this; explicitly specifying "libpng.lib", "zlib.lib" and "libpngd.lib" in your .exe's link command.