2022-07-24 20:13:47 +00:00
# Build from source
2020-10-26 17:12:37 +00:00
2023-04-11 15:42:35 +00:00
Building Nimbus from source ensures that all hardware-specific optimizations are turned on.
The build process itself is simple and fully automated, but may take a few minutes.
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
!!! note "Nim"
2023-04-11 15:42:35 +00:00
Nimbus is written in the [Nim ](https://nim-lang.org ) programming language.
The correct version will automatically be downloaded as part of the build process!
2022-07-21 18:19:47 +00:00
2020-10-26 17:12:37 +00:00
## Prerequisites
2022-07-22 19:47:24 +00:00
!!! tip
If you are planning to use the precompiled binaries, you can skip this section and go straight to the [binaries ](./binaries.md )!
2022-07-21 18:19:47 +00:00
When building from source, you will need additional build dependencies to be installed:
- Developer tools (C compiler, Make, Bash, Git)
2022-07-24 20:13:47 +00:00
- [CMake ](https://cmake.org/ )
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
=== "Linux"
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
On common Linux distributions the dependencies can be installed with
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
```sh
# Debian and Ubuntu
sudo apt-get install build-essential git cmake
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
# Fedora
dnf install @development -tools cmake
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
# Archlinux, using an AUR manager
yourAURmanager -S base-devel cmake
```
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
=== "macOS"
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
With [Homebrew ](https://brew.sh/ ):
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
```sh
brew install cmake
```
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
=== "Windows"
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
To build Nimbus on Windows, the MinGW-w64 build environment is recommended.
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
Install Mingw-w64 for your architecture using the "[MinGW-W64 Online Installer](https://sourceforge.net/projects/mingw-w64/files/)":
2022-07-21 18:19:47 +00:00
2023-04-11 15:42:35 +00:00
1. Select your architecture in the setup menu (`i686` on 32-bit, `x86_64` on 64-bit).
2. Set threads to `win32` .
2022-07-24 20:13:47 +00:00
3. Set exceptions to "dwarf" on 32-bit and "seh" on 64-bit.
2023-04-11 15:42:35 +00:00
4. Change the installation directory to `C:\mingw-w64` and add it to your system PATH in `"My Computer"/"This PC" -> Properties -> Advanced system settings -> Environment Variables -> Path -> Edit -> New -> C:\mingw-w64\mingw64\bin` (`C:\mingw-w64\mingw32\bin` on 32-bit).
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
Install [Git for Windows ](https://gitforwindows.org/ ) and use a "Git Bash" shell to clone and build `nimbus-eth2` .
2022-07-21 18:19:47 +00:00
2023-04-11 15:42:35 +00:00
!!! note
If the online installer isn't working you can try installing `mingw-w64` through [MSYS2 ](https://www.msys2.org/ ).
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
=== "Android"
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
- Install the [Termux ](https://termux.com ) app from FDroid or the Google Play store
- Install a [PRoot ](https://wiki.termux.com/wiki/PRoot ) of your choice following the instructions for your preferred distribution.
Note, the Ubuntu PRoot is known to contain all Nimbus prerequisites compiled on Arm64 architecture (the most common architecture for Android devices).
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
Assuming you use Ubuntu PRoot
2022-07-21 18:19:47 +00:00
2022-07-24 20:13:47 +00:00
```sh
apt install build-essential git
```
2020-10-26 17:12:37 +00:00
## Building the node
2022-06-19 07:24:01 +00:00
### 1. Clone the `nimbus-eth2` repository
2020-10-26 17:12:37 +00:00
2022-06-19 07:24:01 +00:00
```sh
2020-10-26 17:12:37 +00:00
git clone https://github.com/status-im/nimbus-eth2
cd nimbus-eth2
```
2020-11-07 15:52:40 +00:00
### 2. Run the beacon node build process
2020-10-26 17:12:37 +00:00
2022-07-21 18:19:47 +00:00
To build the Nimbus beacon node and its dependencies, run:
2020-10-26 17:12:37 +00:00
2022-06-19 07:24:01 +00:00
```sh
make -j4 nimbus_beacon_node
2020-10-26 17:12:37 +00:00
```
2021-03-05 08:53:55 +00:00
2022-07-22 19:47:24 +00:00
!!! tip
Omit `-j4` on systems with 4GB of memory or less.