简体   繁体   English

如何在Visual Studio 2017中使用zlib库?

[英]How to use zlib library in visual studio 2017?

I want to use the zlib library in my c++ project. 我想在我的c ++项目中使用zlib库。 So, I have downloaded zlib library( zlib_1_2_8_msvc2015_64.zip ). 所以,我已经下载了zlib库( zlib_1_2_8_msvc2015_64.zip )。 Then, I have created zlib folder under "C:\\Program Files\\Zlib" . 然后,我在"C:\\Program Files\\Zlib"下创建了zlib文件夹。 Then, Extract zlib_1_2_8_msvc2015_64.zip file into "C:\\Program Files\\Zlib" . 然后,将zlib_1_2_8_msvc2015_64.zip文件压缩到"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" . 之后,我打开了visual studio 2017并转到属性 => C / C ++ => general => 其他包含目录并添加了该路径: "C:\\Program Files\\Zlib\\msvc2015_64"

After that, I have added #include <zlib.h> header file in my project. 之后,我在项目中添加了#include <zlib.h>头文件。 but, not working. 但是,不工作。

So, How to use zlib library in visual studio 2017? 那么,如何在Visual Studio 2017中使用zlib库?

For static library installation , include the zlibstatic.lib and directories in the linker additional libraries and directories. 对于静态库安装,请在链接器的其他库和目录中包含zlibstatic.lib和目录。 For dynamic library , include the zlib.lib in the linker and copy the zlib.dll to the project output directory. 对于动态库,请在链接器中包含zlib.lib,并将zlib.dll复制到项目输出目录中。

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 . 另一个选择是安装vcpkg(MS packager来安装基于Windows的开源项目)并使用powershell命令.\\vcpkg install zlib:x64-windows-static The zlib can be auto integrated to your project using .\\vcpkg integrate install zlib可以使用.\\vcpkg integrate install自动集成到您的项目中

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: 对于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 在链接器部分 - >输入 - >附加依赖性中,您可以指定要绑定的实际lib名称

它的一个简单修复将msvc2015_64目录的所有内容复制到zlib目录中,你很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM