HOWTO Build 7-Zip for MSVCRT using Visual Studio 2008 Express Edition

Darik Horn
  • Darik Horn

    Darik Horn - 2013-03-15

    The original document is at

    For 32-bit and 64-bit 7-Zip builds linked to MSVCRT.DLL

    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.

    Part A: Requirements

    • Visual Studio 2008 Express Edition with SP1 (VS2008ExpressWithSP1ENUX1504728.iso)
    • Windows SDK 7.0 for x64 (GRMSDKX_EN_DVD.ISO)
    • Windows DDK 7.1 (GRMWDK_EN_7600_1.ISO)
    • win32svn (
    • myomake (

    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.

    Part B: Compiler Installation

    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 myomake

    4. Run the MSVCRT toolchain preparation and configuration script:

    C:\> cd \myomake\trunk\misc\tools\windows\cmsc\tools
    C:\myomake\trunk\misc\tools\windows\cmsc\tools> cmsc_compile.bat


    • The Windows SDK installer may fail to start in step 2 if Visual Studio 2008 does not successfully install the .NET Framework 3.5 SP1 runtime.
    • Use a native SVN client for step 3. Permissions on various files will be incorrect if the Cygwin SVN client is used.

    Part C: Build Instructions

    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.

    --- a/CPP/7zip/UI/FileManager/MyWindowsNew.h
    +++ b/CPP/7zip/UI/FileManager/MyWindowsNew.h
    @@ -49,8 +49,6 @@
       TBPF_PAUSED = 0x8
     } TBPFLAG;
    -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>
    cd \7z922\CPP\7zip\Bundles

    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.


    • Capitalization and quoting matters for step 5.
    • Build products are put in the \AMD64 or \i386 folder of each bundle. (eg: C:\7z922\CPP\7zip\Bundles\Fm\AMD64\7zFM.exe)
    • The top-level makefile does not have a clean rule. Just delete the \AMD64 and \i386 folders between builds.
    Appendix 1: MD5 File Hashes
    83b3292c1aa8e4d3eb0c6bcd66a55cd0 *VS2008ExpressWithSP1ENUX1504728.iso
    1081c87025a5a507a55426ac59222b7a *GRMSDKX_EN_DVD.ISO
    8fe981a1706d43ad34bda496e6558f94 *GRMWDK_EN_7600_1.ISO
  • Yumeyao

    Yumeyao - 2013-04-27

    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.

  • Yumeyao

    Yumeyao - 2013-04-27

    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.

  • Igor Pavlov

    Igor Pavlov - 2013-04-27

    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.

    Last edit: Igor Pavlov 2013-04-27
    • Yumeyao

      Yumeyao - 2013-04-27

      Thanks for making it clear.
      That explains why the official version is not as inefficient as expected(VC6).

  • Fadi R

    Fadi R - 2017-01-12

    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?

  • Fadi R

    Fadi R - 2017-01-12

    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 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)

    Last edit: Fadi R 2017-01-15

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks