This document shows how to build smartbchd (the executable of smartBCH's full node client). We suggest to use ubuntu 20.04.
We suggest to use GCC-9 because it's the default compiler of ubuntu 20.04. But you call as well use GCC-10 and GCC-11. Just replace the following g++ and gcc with your desired compilers (such as g++-10/gcc-10/g++-11/gcc-11).
sudo sed -i -e '$a* soft nofile 65536\n* hard nofile 65536' /etc/security/limits.conf ;# enlarge count of open files
sudo apt update
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt install make cmake g++ gcc gitThen download and unpack golang (If you are using ARM Linux, please replace "amd64" with "arm64"):
wget https://go.dev/dl/go1.18.linux-amd64.tar.gz
tar zxvf go1.18.linux-amd64.tar.gzAnd set some environment variables for golang:
export GOROOT=~/go
export PATH=$PATH:$GOROOT/bin
mkdir ~/godata
export GOPATH=~/godataAfter installing golang, we need to patch it for larger cgo stack.
wget https://github.com/smartbch/patch-cgo-for-golang/archive/refs/tags/v0.1.2.tar.gz
tar zxvf v0.1.2.tar.gz
rm v0.1.2.tar.gz
cd patch-cgo-for-golang-0.1.2
cp *.c $GOROOT/src/runtime/cgo/firsrt, install rocksdb dependencies.
sudo apt install libgflags-devFor some unknown reason, on some machines with ubuntu 20.04, the default libsnappy does not work well. So we suggest to build libsnappy from source:
mkdir $HOME/build
cd $HOME/build
wget https://github.com/google/snappy/archive/refs/tags/1.1.8.tar.gz
tar zxvf 1.1.8.tar.gz
cd snappy-1.1.8
mkdir build
cd build
CXX=g++ cmake -DBUILD_STATIC_LIBS=On ../
make CC=gcc CXX=g++
sudo make installthen install rocksdb
cd $HOME/build
wget https://github.com/facebook/rocksdb/archive/refs/tags/v5.18.4.tar.gz
tar zxvf v5.18.4.tar.gz
cd rocksdb-5.18.4
curl https://raw.githubusercontent.com/smartbch/artifacts/main/patches/rocksdb.gcc11.patch | git apply -v
CXXFLAGS=-Wno-range-loop-construct make CC=gcc CXX=g++ static_libmore infos can refer to rocksdb install doc
Last, export library path. You should export ROCKSDB_PATH with rocksdb root directory downloaded from above
export ROCKSDB_PATH="$HOME/build/rocksdb-5.18.4" ;#this direct to rocksdb root dircd ~ ;# any directory can do. Here we use home directory for example
mkdir smart_bch
cd smart_bchcd ~/smart_bch
git clone -b v0.4.4 --depth 1 https://github.com/smartbch/moeingevm
cd moeingevm/evmwrap
make
export CGO_CFLAGS="-I$ROCKSDB_PATH/include"
export CGO_LDFLAGS="-L$ROCKSDB_PATH -L$HOME/smart_bch/moeingevm/evmwrap/host_bridge/ -l:librocksdb.a -lstdc++ -lm -lsnappy "After successfully executing the above commands, you'll get a ~/smart_bch/moeingevm/evmwrap/host_bridge/libevmwrap.a file.
cd ~/smart_bch
git clone -b v0.4.7 --depth 1 https://github.com/smartbch/smartbch
cd smartbch
go build -tags cppbtree github.com/smartbch/smartbch/cmd/smartbchdAfter successfully executing the above commands, you'll get a ~/smart_bch/smartbch/smartbchd file.