Windows10, compiled zlib

Windows10, compile zlib.

First, download zlib

  I downloaded the first, US (zlib.net).

I downloaded the zlib-1.2.11, can be downloaded extract it. Below began to compile it. (Including dynamic and static libraries, two)

Second, the compiler

1. Open a command window of VS2010, Run as administrator

2, switch to zlib / contrib / masmx86, run bld_ml32.bat. If a 64-bit, switch to zlib / contrib / masmx64, run bld_ml64.bat

After 3, 32-bit operation, in this folder inside, generating more than two * .obj files.

4, zlib's vs sln solution file can be found in the following path: zlib-1.2.5 / contrib / vstudio / vc10 / zlibvc.sln, open the solution includes six projects. among them:

(1). Zlibvc generating a dynamic link library zlibwapi.dll and corresponding import library zlibwapi.lib. Right this project, directly generated.

Results --->  

(2). Zlibstat generate static link library zlibstat.lib. Right this project, directly generated.

(3). Testzlibdll test generation of dynamic link library zlibwapi.dll. Right this project, directly generated.

Error: 2> LINK: fatal error LNK1104: can not open file "x86 \ ZlibDllDebug \ zlibwapi.lib"

A success, a failure.

(4). Testzlib test static link library zlibstat.lib generated. Right this project, directly generated.

(5) Finally, we compiled in debug mode, the entire solution. Generated dll and lib files can be found in the appropriate folder.

Here we zlibstat.lib static libraries and dynamic libraries (zlibwapi.dll / zlibwapi.lib) and zlib.h / zlibconf.h files in a folder. Easy to use for future projects.

 

三、使用

下边介绍如何使用编译好的动态或是静态库。(假设项目工程已经建立完毕

1. zlib静态库:zlibstat.lib

  1. 包含头文件

    属性–C/C+±-常规–附加包含目录(添加包含.h文件的目录)

  2. 定义宏

    属性–C/C+±-预处理器–预处理器定义:添加 ZLIB_WINAPI ASMV ASMINF

  3. 项目包含.lib文件所在的目录:

    属性–链接器–常规–附加库目录

  4. 项目包含.lib文件

    属性–链接器–输入–附加依赖项(libstat.lib)

  5. 项目代码中 #include “zlib.h”

编译生成.exe即可使用。

2. 动态库 zlibwapi.lib

  1. 包含头文件

    属性–C/C+±-常规–附加包含目录(添加包含.h的目录)

  2. 定义宏

    属性–C/C+±-预处理器–预处理器定义:添加 ZLIB_WINAPI

  3. 项目包含.lib文件所在的目录:

    属性–链接器–常规–附加库目录

  4. 项目包含.lib文件

    属性–链接器–输入–附加依赖项(zlibwapi.lib)

  5. 项目代码中 #include “zlib.h”

编译生成.exe文件需要.dll文件支持(动态加载)

参考链接:https://blog.csdn.net/u011740322/article/details/51207809

发布了384 篇原创文章 · 获赞 110 · 访问量 4万+

Guess you like

Origin blog.csdn.net/qq_34732729/article/details/104270047