doc/html/en/CompilingGuidelineWin.html
Documentation Technical Details Building VeraCrypt From Source Windows Build Guide
This guide describes how to set up a Windows system that can compile the VeraCrypt. Further it is described how VeraCrypt is going to be compiled.
The procedure for a Windows 10 system is described here as an example, but the procedure for other Windows systems is analogous.
The following components are required for compiling VeraCrypt:
Below are the procedure steps. Clicking on any of the link takes directly to the related step:
Installation of Microsoft Visual Studio 2010
The installation of the Microsoft SQL Server 2008 Express Service Pack 1 (x64) may fail, but it is not required for compiling VeraCrypt.
Installation of Microsoft Visual Studio 2010 Service Pack 1
Note: The content the official installer from Microsoft tries to download is no longer available. Therefore, it is necessary to use an offline installer.
Download “nasm-2.08-installer.exe” at:
https://www.nasm.us/pub/nasm/releasebuilds/2.08/win32/
Run the file as administrator
Install NASM with the default settings
Add NASM to the path Variable. This will make the command globally available on the command line.
Open a file explorer
Within the left file tree, please make a right click on "This PC" and select "Properties"
Within the right menu, please click on "Advanced system settings"
Please click on "Environment Variables"
Within the area of the system variables, please select the "Path" variable and click on "Edit..."
Click on "New" and add the following value:
C:\Program Files (x86)\nasm
Close the windows by clicking on "OK"
To check if the configuration is working correctly, please open a command prompt and watch the output of the following command:
nasm
Please create the following folder:
C:\Program Files\YASM
Please download the file "Win64 VS2010 .zip" at:
https://yasm.tortall.net/Download.html
Your browser might inform you that the file might be a security risk due to the low download rate or the unencrypted connection. Nevertheless, the official website is the most reliable source for this file, so we recommend to allow the download
Unzip the zip file and copy the files to “C:\Program Files\YASM”
Please download the file "Win64 .exe" at:
https://yasm.tortall.net/Download.html
Your browser might inform you that the file might be a security risk due to the low download rate or the unencrypted connection. Nevertheless, the official website is the most reliable source for this file, so we recommend to allow the download
Rename the file to “yasm.exe” and copy it to “C:\Program Files\YASM”
Add YASM to the path Variable and create a new system variable for YASM. This will make the command globally available on the command line.
Open a file explorer
Within the left file tree, please make a right click on "This PC" and select "Properties"
Within the right menu, please click on "Advanced system settings"
Please click on "Environment Variables"
Within the area of the system variables, please select the "Path" variable and click on "Edit..."
Click on "New" and add the following value:
C:\Program Files\YASM
Variable name: YASMPATH
Variable value: C:\Program Files\YASM
Close the windows by clicking on "OK"
To check if the configuration is working correctly, please open a command prompt and watch the output of the following command:
yasm
and
vsyasm
Installation of Microsoft Visual C++ 1.52
Visual C++ 1.52 is available via the paid Microsoft MSDN subscription. If you do not have a subscription, you download the ISO image via the internet archive:
https://archive.org/details/ms-vc152
Create the folder “C:\MSVC15”
Mount the ISO file and copy the content of the folder “MSVC” to “C:\MSVC15”
Create a system variable for Microsoft Visual C++ 1.52
Open a file explorer
Within the left file tree, please make a right click on "This PC" and select "Properties"
Within the right menu, please click on "Advanced system settings"
Please click on "Environment Variables"
Within the area of the system variables, please click on "New..."
Fill out the form with the following values:
Variable name: MSVC16_ROOT
Variable value: C:\MSVC15
Installation of the Windows SDK 7.1
The installer requires .Net Framework 4 (Not a newer one like .Net Framework 4.8!). Since a newer version is already preinstalled with Windows 10, the installer has to be tricked:
Click on the start button and search for: "regedit.msc". Start the first finding.
Navigate to "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4"
Change the permissions for the "Client" folder, so you can edit the keys:
Right click on the subfolder "Client" and select "Permissions..."
Click on "Advanced"
Change the owner to your user and click on "Add"
Set the principal to your user, select "Full Control" and click on "OK"
Within the folder "Client" note down the value of the entry "Version"
Doubleclick on the entry "Version" and change the value to "4.0.30319"
Change the permissions for the "Full" folder, so you can edit the keys:
Right click on the subfolder "Full" and select "Permissions..."
Click on "Advanced"
Change the owner to your user and click on "Add"
Set the principal to your user, select "Full Control" and click on "OK"
Within the folder "Full" note down the value of the entry "Version"
Doubleclick on the entry "Version" and change the value to "4.0.30319"
Download the Windows SDK 7.1 at:
https://www.microsoft.com/en-us/download/details.aspx?id=8279
Run the downloaded file as administrator and install the application with default settings
After the installation, revert the changes done in the registry editor.
Note: The owner "TrustedInstaller" can be restored by searching for: "NT Service\TrustedInstaller"
Installation of the Windows Driver Kit 7.1
Installation of the Windows 8.1 SDK
Please download the ISO of the Windows 8.1 SDK at:
https://developer.microsoft.com/de-de/windows/downloads/sdk-archive/
Run the downloaded file as administrator and install the Windows 8.1 SDK with default settings
Create a system variable for the Windows 8.1 SDK
Open a file explorer
Within the left file tree, please make a right click on "This PC" and select "Properties"
Within the right menu, please click on "Advanced system settings"
Please click on "Environment Variables"
Within the area of the system variables, please click on "New..."
Fill out the form with the following values:
Variable name: WSDK81
Variable value: C:\Program Files (x86)\Windows Kits\8.1\
Please create the following folder:
C:\Program Files (x86)\gzip
Please download gzip version at:
https://sourceforge.net/projects/gnuwin32/files/gzip/1.3.12-1/gzip-1.3.12-1-bin.zip/download?use-mirror=netix&download=
Copy the content of the downloaded zip to “C:\Program Files (x86)\gzip”
Add gzip to the path Variable. This will make the command globally available on the command line.
Open a file explorer
Within the left file tree, please make a right click on "This PC" and select "Properties"
Within the right menu, please click on "Advanced system settings"
Please click on "Environment Variables"
Within the area of the system variables, please select the "Path" variable and click on "Edit..."
Click on "New" and add the following value:
C:\Program Files (x86)\gzip\bin
Close the windows by clicking on "OK"
To check if the configuration is working correctly, please open a command prompt and watch the output of the following command:
gzip
Please create the following folder:
C:\Program Files (x86)\upx
Please download the latest upx-X-XX-win64.zip version at:
https://github.com/upx/upx/releases/tag/v3.96
Copy the content of the downloaded zip to “C:\Program Files (x86)\upx”
Add gzip to the path Variable. This will make the command globally available on the command line.
Open a file explorer
Within the left file tree, please make a right click on "This PC" and select "Properties"
Within the right menu, please click on "Advanced system settings"
Please click on "Environment Variables"
Within the area of the system variables, please select the "Path" variable and click on "Edit..."
Click on "New" and add the following value:
C:\Program Files (x86)\upx
Close the windows by clicking on "OK"
To check if the configuration is working correctly, please open a command prompt and watch the output of the following command:
upx
Installation of Microsoft Visual Studio 2019
Visit the following Microsoft website and log in with a free Microsoft account:
https://my.visualstudio.com/Downloads?q=visual%20studio%202019%20Professional
Please download the latest (trial) version of “Visual Studio Professional 2019”
Run the downloaded file as administrator and go through the wizard.
Select the following Workloads for installation:
Desktop development with C++
.NET desktop development
Select the following individual components for installation:
.NET 1. .NET 6.0 Runtime 2. .NET Core 3.1 Runtime (LTS) 3. .NET Framework 4 targeting pack 4. .NET Framework 4.5 targeting pack 5. .NET Framework 4.5.1 targeting pack 6. .NET Framework 4.5.2 targeting pack 7. .NET Framework 4.6 targeting pack 8. .NET Framework 4.6.1 targeting pack 9. .NET Framework 4.7.2 targeting pack 10. .NET Framework 4.8 SDK 11. .NET Framework 4.8 targeting pack 12. .NET SDK 13. ML.NET Model Builder (Preview)
Cloud, database, and server 1. CLR data types for SQL Server 2. Connectivity and publishing tools
Code tools 1. NuGet package manager 2. Text Template Transformation
Compilers, build tools, and runtimes 1. .NET Compiler Platform SDK 2. C# and Visual Basic Roslyn compilers 3. C++ 2019 Redistributable Update 4. C++ CMake tools for Windows 5. C++/CLI support for v142 build tools (Latest) 6. MSBuild 7. MSVC v142 - VS 2019 C++ ARM64 build tools (Latest) 8. MSVC v142 - VS 2019 C++ ARM64 Spectre-mitigated libs (Latest) 9. MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest) 10. MSVC v142 - VS 2019 C++ x64/x86 Spectre-mitigated libs (Latest)
Debugging and testing 1. .NET profiling tools 2. C++ AddressSanatizer 3. C++ profiling tools 4. Just-In-Time debugger 5. Test Adapter for Boost.Test 6. Test Adapter for Google Test
Development activities 1. C# and Visual Basic 2. C++ core features 3. F# language support 4. IntelliCode 5. JavaScript and TypeScript language support 6. Live Share
Emulators NONE
Games and Graphics 1. Graphics debugger and GPU profiler for DirectX
SDKs, libraries, and frameworks 1. C++ ATL for latest v142 build tools (ARM64) 2. C++ ATL for latest v142 build tools (x86 & x64) 3. C++ ATL for latest v142 build tools with Spectre Mitigations (ARM64) 4. C++ ATL for latest v142 build tools with Spectre Mitigations (x86 & x64) 5. C++ MFC for latest v142 build tools (ARM64) 6. C++ MFC for latest v142 build tools (x86 & x64) 7. C++ MFC for latest v142 build tools with Spectre Mitigations (ARM64) 8. C++ MFC for latest v142 build tools with Spectre Mitigations (x86 & x64) 9. Entity Framework 6 tools 10. TypeScript 4.3 SDK 11. Windows 10 SDK (10.0.19041.0) 12. Windows Universal C Runtime
Installation of the Windows Driver Kit version 2004
Installation of the Visual Studio build tools
Visit the following Microsoft website and log in with a free Microsoft account:
https://my.visualstudio.com/Downloads?q=visual%20studio%202019%20build%20tools
Please download the latest version of “Build Tools for Visual Studio 2019”
Run the downloaded file as administrator and go through the wizard. Select the following individual components for installation:
.NET NONE
Cloud, database, and server NONE
Code tools NONE
Compilers, build tools, and runtimes 1. C++/CLI support for v142 build tools (Latest) 2. MSVC v142 - VS 2019 C++ ARM64 build tools (Latest) 3. MSVC v142 - VS 2019 C++ ARM64 Spectre-mitigated libs (Latest) 4. MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest) 5. MSVC v142 - VS 2019 C++ x64/x86 Spectre-mitigated libs (Latest)
Debugging and testing NONE
Development activities NONE
SDKs, libraries, and frameworks 1. C++ ATL for latest v142 build tools (ARM64) 2. C++ ATL for latest v142 build tools (x86 & x64) 3. C++ ATL for latest v142 build tools with Spectre Mitigations (ARM64) 4. C++ ATL for latest v142 build tools with Spectre Mitigations (x86 & x64)
Download VeraCrypt Source Files
Compile the Win32/x64 Versions of VeraCrypt
Compile the ARM64 Version of VeraCrypt
Build the VeraCrypt Executables
With the sign_test.bat script you just signed the VeraCrypt executables. This is necessary, since Windows only accepts drivers, which are trusted by a signed Certificate Authority.
Since you did not use the official VeraCrypt signing certificate to sign your code, but a public development version, you have to import and therefore trust the certificates used.
Note: If prompted, the password for .pfx certificates is idrix.
On Windows 10 or higher you might get the error message above. In order to avoid this, you will need to:
Please see https://sourceforge.net/p/veracrypt/discussion/technical/thread/83d5a2d6e8/#db12 for further details.
Another approach is to disable the signature verification in the VeraCrypt code. This should be done only for testing purposes and not for production use:
if (!IsOSAtLeast (WIN_10))
return TRUE;
Replace:
return TRUE;
Windows validates the signature for every driver which is going to be installed.
For security reasons, Windows allows only drivers signed by Microsoft to load.
So, when using a custom build:
Potential Causes for Installation Failure under "Test Mode":
4.