Build executable binaries natively for Windows

Before proceeding, ensure that the hardware and software requirements are met.

Installing Chocolatey

Install Chocolatey package manager by following these instructions.

Once your Windows machine has the above installed, open the Command Prompt by typing "cmd" in the search bar and check that you have correctly installed Chocolatey:

choco -v

Now you need to install the following components: cmake, make, mingw by:

choco install cmake make mingw

Important note about Anti-Virus:

During the compiler detection phase of MinGW, some temporary executable files are generated to test the compiler capabilities. It's been reported that some anti-virus programs detect these files as possibly infected with the Win64/Kryptic.CIS Trojan horse (or a variant of it). Although these are false positives, we have no control over the 100+ vendors of security products for Windows and their respective detection algorithms and we understand that this may make your experience with Windows builds uncomfortable. To work around this, you can either set exclusions for your antivirus software specifically for thebuild\bin\mdbx\CMakeFiles subfolder of the cloned repo, or you can run Erigon using the other two options below.

Make sure that the Windows System Path variable is set correctly. Use the search bar on your computer to search for “Edit the system environment variable”.

Click the “Environment Variables...” button.

Look down at the "System variables" box and double click on "Path" to add a new path.

Then click on the "New" button and paste the following path:

 C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin

Clone the Erigon repository

Open the Command Prompt and type the following:

git clone --branch v3.0.0-beta1 --single-branch https://github.com/erigontech/erigon.git

You might need to change the ExecutionPolicy to allow scripts created locally or signed by a trusted publisher to run:

Set-ExecutionPolicy RemoteSigned

Compiling Erigon

To compile Erigon there are two alternative methods:

  1. Compiling from the wmake.ps1 file in the File Explorer
  2. Using the PowerShell CLI

1. Compiling from the wmake.ps1 file in the File Explorer

This is the fastest way which normally works for everyone. Open the File Explorer and go to the Erigon folder, then right click the wmake file and choose "Run with PowerShell".

PowerShell will compile Erigon and all of its modules. All binaries will be placed in the .\build\bin\ subfolder.

2. Using the PowerShell CLI

In the search bar on your computer, search for “Windows PowerShell” and open it.

Change the working directory to "erigon"

cd erigon

Before modifying security settings, ensure PowerShell script execution is allowed in your Windows account settings using the following command:

Set-ExecutionPolicy Bypass -Scope CurrentUser -Force

This change allows script execution, but use caution to avoid security risks. Remember to only make these adjustments if you trust the scripts you intend to run. Unauthorized changes can impact system security. For more info read Set-Execution Policy documentation.

Now you can compile Erigon and/or any of its component:

.\wmake.ps1 [-target] <targetname>

For example, to build the Erigon executable write:

.\wmake.ps1 erigon

The executable binary erigon.exe should have been created in the .\build\bin\ subfolder.

You can use the same command to build other binaries such as RPCDaemon, TxPool, Sentry and Downloader.

Running Erigon

To start Erigon place your command prompt in the .\build\bin\ subfolder and use:

start erigon.exe.

or from any place use the full address of the executable:

start C:\Users\username\AppData\Local\erigon.exe

See basic usage documentation on available options and flags to customize your Erigon experience.