Win10 under Visual Studio 2015,c++ compilation zlib

Source: Internet
Author: User



The premise installs the Visual Studio. PS. Almost all the way, x64 compilation will be a bit of a pit, in view of the online x86 compile way very much, so no longer cumbersome x86 compilation



zlib Download Source:



Official website: http://zlib.net/



Download: Http://zlib.net/zlib128.zip






Mode one: Command mode



1, decompression zlib128.zip, any place can, I decompression in e:\zlib128\zlib-1.2.8,zlib-1.2.8 for the root directory



2, in this way, the first need to add the VC directory of Visual Studio into the environment variables of the system, the Advanced system settings (high-level systems setup), at the bottom of advanced, Click enviroment Variable (environment variable), System Variables (systems variable) path, add the corresponding VC directory path (Visual studio does not divide x86 and x64, the main part is installed in program Files ( x86) My directory for C:\Program Files (x86) \microsoft Visual Studio 14.0\VC , after adding, log off or restart



3. Open the Start menu, select the visual Studio (available after Visual Studio), select VS2015 x64 Native Tools Command Prompt (VS2015 x64 Local command-line tools), ( note here, many tutorials need to use this tool to zlib-1.2.8 contrib/masmx64 below to execute Bld_ml64.bat build inffasx64.obj files, in fact these steps are redundant , you can notice that zlib-1.2.8 root directory has a corpus love your home for Win32, this is the key to compile, open inside there is a file for Makefile.msc, this is NMAKE need to use the Makefile. Opening the file with EditPad can be seen as follows:



      



PS. Some of the other tutorials are redundant because the following content in the file automatically looks for the relevant file, generating the corresponding obj file


gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm

inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm

inffas8664.obj: $(TOP)/contrib\masmx64\inffas8664.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h 		$(TOP)/inftrees.h $(TOP)/inflate.h $(TOP)/inffast.h


Next, look at the contents of the file, at the beginning of the comment there is a way to compile


# Usage:
#   nmake -f win32/Makefile.msc                          (standard build)
#   nmake -f win32/Makefile.msc LOC=-DFOO                (nonstandard build)
#   nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" #         OBJA="inffas32.obj match686.obj"               (use ASM code, x86)
#   nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." #         OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"  (use ASM code, x64)


Then, in the command line, enter E: Jump to the E-disk, enter the CD E:\zlib128\zlib-1.2.8 to the root directory, enter nmake-f win32/makefile.msc as=ml64 loc= "-dasmv-dasminf-i." Obja= "Inffasx64.obj gvmat64.obj inffas8664.obj", the program will run up,






At this point, the compilation has been completed, the root directory will appear related to the result file zlib.lib,zlib1.dll,zlib.pdb and so on.



Note that if you fill the system environment variable, or do not copy the Vc\bin\amd64\ml64.exe to the root directory, run compiled makefile some of the necessary 32-bit obj after the error will stop as follows


Tip 1:
Inffas8664.c
         Lib -nologo -out:zlib.lib adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr. Obj zutil.obj inffasx64.obj gvmat64.obj inffas8664.obj
Inffasx64.obj : fatal error LNK1112: Module computer type "x64" conflicts with target computer type "X86"
NMAKE : fatal error U1077: ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\lib.EXE"": Return code "0x458"
Stop.

Tip 2:
         Ml64 -c -coff -Zi -DASMV -DASMINF -I. ./contrib/masmx64\inffasx64.asm
‘ml64’ is not an internal or external command, nor is it a runnable program
Or batch file.
NMAKE : fatal error U1077: "ml64": return code "0x1"
Stop.





Method Two: Compiling with the Visual Studio IDE



1, open E:\ZLIB128\ZLIB-1.2.8\CONTRIB\VSTUDIO\VC11, double-click Zlibvc.sln,visual Studio 2015 will open it, but this sln is created with vs2012, so the popup window prompt, Need to update the relevant file configuration, click OK






2, Next bar in the menu bar output platform Select bit x64, right click ZLIBVC, in the pop-up menu click Build, will start error as follows


Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command "cd ..\..\contrib\masmx64
bld_ml64.bat
:VCEnd" exited with code 9009.	zlibvc	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets	123	


The resulting eng of this error is a pre-build event from the build time, because the bat file cannot be accurately found through the path execution



3, the solution is as follows: Right click on the ZLIBVC, select Properties in the pop-up menu, select the Build event in the pop-up Properties dialog box (Generate events), click Pre-build Event (pre-generated events), you will see command line There is a command line in the error prompt, where we modify it, click the drop-down button next to the command, then click Edit, the content is deleted and replaced as follows: (the content here can be referred to the command line)


E:CD E:\zlib128\zlib-1.2.8\contrib\masmx64bld_ml64.bat


Add the number after the person close, and then re-execute the second step to compile, found that the normal compilation has started, but later reported a mistake as follows, just double-click the error, will automatically open a. def file, change the Verson line of 1.2.8 to 1.28, and then save


Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK1118	syntax error in ‘VERSION‘ statement	zlibvc	E:\zlib128\zlib-1.2.8\contrib\vstudio\vc11\zlibvc.def	4	


Re-perform the second operation to compile, at which point a successful message will be prompted, as follows


1>------ Build started: Project: zlibvc, Configuration: Debug x64 ------
1>  Microsoft (R) Macro Assembler (x64) Version 14.00.24210.0
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>
1>   Assembling: inffasx64.asm
1>   Assembling: gvmat64.asm
1>  Microsoft (R) Macro Assembler (x64) Version 14.00.24210.0
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>
1>     Creating library x64\ZlibDllDebug\zlibwapi.lib and object x64\ZlibDllDebug\zlibwapi.exp
1>  zlibvc.vcxproj -> E:\zlib128\zlib-1.2.8\contrib\vstudio\vc11\x64\ZlibDllDebug\zlibwapi.dll
1>  zlibvc.vcxproj -> x64\ZlibDllDebug\zlibwapi.pdb (Full PDB)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


The corresponding output file will appear in the E:\zlib128\zlib-1.2.8\contrib\vstudio\vc11\x64\ZlibDllDebug directory,






At this point, all the compilation work is done, the ps.x86 Visual Studio IDE compiles the way, does not need to modify anything to compile completes.












  



Win10 under Visual Studio 2015,c++ compilation zlib


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.