Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use zlib library in visual studio 2017?

I want to use the zlib library in my c++ project. So, I have downloaded zlib library(zlib_1_2_8_msvc2015_64.zip). Then, I have created zlib folder under "C:\Program Files\Zlib". Then, Extract zlib_1_2_8_msvc2015_64.zip file into "C:\Program Files\Zlib".

After that, I have opened visual studio 2017 and goes to property => C/C++ => general => additional include directories and added that path : "C:\Program Files\Zlib\msvc2015_64".

After that, I have added #include <zlib.h> header file in my project. but, not working.

So, How to use zlib library in visual studio 2017?

like image 576
Jayesh Avatar asked Mar 27 '18 06:03

Jayesh


People also ask

How do I add a library in Visual Studio 2017?

Linker -> Input you'll add the actual library files under Additional Dependencies. For the Header Files you'll also want to include their directories under C/C++ -> Additional Include Directories. If there is a dll have a copy of it in your main project folder, and done.


2 Answers

For static library installation , include the zlibstatic.lib and directories in the linker additional libraries and directories. For dynamic library , include the zlib.lib in the linker and copy the zlib.dll to the project output directory.

Another option is to install vcpkg ( MS packager to install windows based open source projects) and use powershell command like so .\vcpkg install zlib:x64-windows-static. The zlib can be auto integrated to your project using .\vcpkg integrate install

like image 101
seccpur Avatar answered Sep 20 '22 05:09

seccpur


You have specified where to find the header files.

You also need to find which library to bind and where to find it.

For Visual Studio 2012:

In linker section -> General -> additional library directories, you can specify the path where the library resides

In linker section -> Input -> additional dependancy , you can specify the actual lib name to bind

like image 40
Pras Avatar answered Sep 22 '22 05:09

Pras