The original document is at https://docs.google.com/document/d/1f40k9euEzBQMOw4p-mgQ2qYlQfaOeqxP6S2DRmg-zDY/edit?usp=sharing
This document is a step-by-step tutorial for building 7-Zip from source on Microsoft Windows without a redistributable runtime dependency, much like the official 7-Zip release packages.
Visual C++ 2008, Windows SDK 7.0, and Windows DDK 7.1 are all based on the 9.00.30729 compiler. Visual C++ 2010 and Windows SDK 7.1 are based on version 10, but a corresponding Windows DDK, which provides the import library, is not available.
Microsoft published Windows SDK 7.0 and Windows SDK 7.1 with the same file name. Verify the MD5 hashes given below.
Other editions of Visual Studio 2008 can be used, but Service Pack 1 is required.
1. Install Visual C++ 2008 before any other component and reboot.
2. Install win32svn, Windows SDK 7.0, and Windows DDK 7.1 with default configurations.
3. Open a command prompt and use SVN to download myomake like this:
C:\Documents and Settings\Administrator> cd \
C:\> "C:\Program Files (x86)\Subversion\bin\svn.exe" checkout https://myomake.svn.sourceforge.net/svnroot/myomake myomake
4. Run the MSVCRT toolchain preparation and configuration script:
C:\> cd \myomake\trunk\misc\tools\windows\cmsc\tools
1. Unpack the 7z922.tar.bz2 source tarball to the C:\7z922 folder.
2. Apply this patch to the source code. Long lines must be unwrapped.
@@ -49,8 +49,6 @@
TBPF_PAUSED = 0x8
-DEFINE_GUID(IID_ITaskbarList3, 0xEA1AFB91, 0x9E28, 0x4B86, 0x90, 0xE9, 0x9E, 0x9F, 0x8A, 0x5E, 0xEF, 0xAF);
struct ITaskbarList3: public ITaskbarList2
STDMETHOD(SetProgressValue)(HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) = 0;
@@ -69,4 +67,6 @@
+DEFINE_GUID(IID_ITaskbarList3, 0xEA1AFB91, 0x9E28, 0x4B86, 0x90, 0xE9, 0x9E, 0x9F, 0x8A, 0x5E, 0xEF, 0xAF);
\ No newline at end of file
(This patch means “move the DEFINE_GUID line to just above the last #endif line”.)
3. Open a regular command prompt change directory into the Bundles folder:
C:\Documents and Settings\Administrator>
4. Run setenv.bat for the myomake toolchain:
C:\7z922\CPP\7zip\Bundles> C:\myomake\trunk\misc\tools\windows\cmsc\setenv.bat /amd64
Setting build environment for amd64
5. And compile the entire 7-Zip project like this:
C:\7z922\CPP\7Zip\Bundles> nmake NEW_COMPILER=1 CPU=AMD64 “LIBS=uuid.lib msvcrt_win2003.obj” all
6. For a 32-bit build, substitute /i386 in step 4 and CPU=i386 in step 5.
I use VC 2005 for 32-bit build and VC 2012 for 64-bit build.
After VC 2005, M$ 32-bit compilers' generated binaries don't have any improvements, especially for C language.
So there are only 2 meaningful ways to use a newer compiler:
1. Targeting very latest (SNB/IVB currently) CPUs for CPU specific optimization.
2. Favor of very latest C++ syntax.
And for 64-bit, M$ is really keeping improving their compiler, so the later the better.
For VC2005, you can manage to search for DDK 2003, which contains the compatible headers for VC2005.
BTW, I don't see any points building yourself now unless you make patches to 7-zip.
The latest official source available is about 2 years ago.
Even though the official (alpha version) binary is built with legacy and stupid VC6, it outperforms the old 9.22 beta binary built with a new compiler.
I compile C files (LZMA, PPMd, and some other code) with VC2010 Express Edition for 32-bit 7-Zip. And I use VC6 for C++ files and linking.
Thanks for making it clear.
That explains why the official version is not as inefficient as expected(VC6).
This really awesome tutorial is 4 years old now. I was wondering if it is still up to date if I want to compile 7zip in 2017?
Darik, I cannot thank you enough for making this tutorial. I would not have really had any ideas where to start without it.
I just managed to compile 16.3 x64 but there are a couple of things I would add to the tutorial.
myomake is now CMSC:
The author of myomake moved his project from the sourcefourge svn to https://github.com/mturk/cmsc.git and renamed the project to CMSC. It's still pretty much the same thing and hasn't been touched for the last 5 years. The win32svn part of the tutorial can also be skipped as the entire project can be downloaded directly from the github site as a zip file.
Be aware that the x86, ia64 and wget EXEs (but none of the amd64 ones) have many positives on virustotal. Most probably false postives but if you don't want to take the chance, cmsc15_compile.bat will still do its work without any errors in the absense of all exe files.
The whole cmsc project (at least for the 7z build) can actually be condensed to the following files and still work:
\tools\crt* (the whole directory)
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.