Compile from Sources
You can download prebuilt binaries here.
If you still want to compile sources yourself, follow the instructions below.
This is a simplified quick build guide.
If you are building for production and not for home use, it's better to use autobuild scripts.
Common
The software is likely to compile and work properly on most Linux systems. It should work on macOS and even Windows.
- Download the newest version of TON Blockchain sources available at the GitHub repository https://github.com/ton-blockchain/ton/:
git clone --recurse-submodules https://github.com/ton-blockchain/ton.git
- Install the newest versions of:
make
cmake
version 3.0.2 or laterg++
orclang
(or another C++14-compatible compiler as appropriate for your operating system).- OpenSSL (including C header files) version 1.1.1 or later
build-essential
,zlib1g-dev
,gperf
,libreadline-dev
,ccache
,libmicrohttpd-dev
,pkg-config
,libsodium-dev
,libsecp256k1-dev
On Ubuntu
apt update
sudo apt install build-essential cmake clang openssl libssl-dev zlib1g-dev gperf libreadline-dev ccache libmicrohttpd-dev pkg-config libsodium-dev libsecp256k1-dev
- Suppose that you have fetched the source tree to directory
~/ton
, where~
is your home directory, and that you have created an empty directory~/ton-build
:
mkdir ton-build
Then run the following in a terminal of Linux or MacOS:
cd ton-build
export CC=clang
export CXX=clang++
cmake -DCMAKE_BUILD_TYPE=Release ../ton && cmake --build . -j$(nproc)
On MacOS
Prepare the system by installing required system packages
brew install ninja libsodium libmicrohttpd pkg-config automake libtool autoconf gnutls
brew install llvm@16
Use newly installed clang.
export CC=/opt/homebrew/opt/llvm@16/bin/clang
export CXX=/opt/homebrew/opt/llvm@16/bin/clang++
Compile secp256k1
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
secp256k1Path=`pwd`
git checkout v0.3.2
./autogen.sh
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark
make -j12
and lz4:
git clone https://github.com/lz4/lz4
cd lz4
lz4Path=`pwd`
git checkout v1.9.4
make -j12
and relink OpenSSL 3.0
brew unlink openssl@1.1
brew install openssl@3
brew unlink openssl@3 && brew link --overwrite openssl@3
Now you can compile TON
cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DSECP256K1_FOUND=1 \
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a \
-DLZ4_FOUND=1 \
-DLZ4_LIBRARIES=$lz4Path/lib/liblz4.a \
-DLZ4_INCLUDE_DIRS=$lz4Path/lib
:::
If you are compiling on a computer with low memory (e.g., 1 Gb), don't forget to create a swap partitions.
Download Global Config
For tools like lite client you need to download the global network config.
Download the newest configuration file from https://ton-blockchain.github.io/global.config.json for mainnet:
wget https://ton-blockchain.github.io/global.config.json