There is a lot of posts about how to compile EOS on MacOS and Ubuntu, and the EOS offical github site has given a complete compile procedure guidence & automatic scripts to help the developers.
However the choice of operting system is subjected to the actual cluster we use in production environment, and the official did not give a clue how to compile on different systems. According to my own compile practice, there are a lot of bugs and traps that need to be avoid when you compile the EOS. To help the developers who are anxious to experience the EOS on their prefered operating system, I write the following article to demonstrate how I compile on CentOS 7 and how to avoid the traps that hidden under the offical guide.
Due to the requirements of building LLVM WebAssembly,the host must have 10GB free space and the RAM need to be greater than 16GB, multiple cpu cores is suggested.
The operating system we use is CentOS 7.4 , you may choose other Redhat releases.
According to the description on EOS.IO github official site,the EOS project is composed on C++14 stander, the default compile come with CentOS 7 is GNU 4.8.5, thus we need to manual choose different repos to install higher verison of GNU compile toolchain. Besides, the CMake version in CentOS 7 official site is a bit old, we need to install the newest Cmake manually.
export BUILD_TEMP=${HOME}/tmp
mkdir ${BUILD_TEMP}
##GNU C++ 6.3.1
sudo yum install -y centos-release-scl
sudo yum install -y devtoolset-6
##CMake 3.10.2
export BUILD_TEMP=${HOME}/tmp
mkdir ${BUILD_TEMP}
cd ${BUILD_TEMP}
mkdir ${HOME}/opt
curl -L https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz -o cmake-3.10.2-Linux-x86_64.tar.gz
tar -zxf cmake-3.10.2-Linux-x86_64.tar.gz -C ${HOME}/opt
export PATH=$PATH:/opt/rh/devtoolset-6/root/bin/:${HOME}/opt/cmake-3.10.2-Linux-x86_64/bin/
##Other compile tool chain
sudo yum install -y git autoconf automake libtool doxygen ocaml gmp-devel python-devel bzip2-devel openssl-devel libicu-devel bzip2 wget
According to the official site, compile EOS.IO requires following components:
export BOOST_ROOT=${HOME}/opt/boost_1_64_0
cd ${BUILD_TEMP}
curl -L https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.bz2 > boost_1.64.0.tar.bz2
tar xvf boost_1.64.0.tar.bz2
cd boost_1_64_0/
./bootstrap.sh "--prefix=$BOOST_ROOT"
./b2 install
cd ${BUILD_TEMP}
git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh && ./configure
make
sudo make install
cd ${BUILD_TEMP}
git clone https://github.com/WebAssembly/binaryen
cd binaryen
git checkout tags/1.37.14
cmake . && make -j 4
sudo make install
DLLVM_TARGETS_TO_BUILD='host' to the cmake configuration), otherwise we would encounter missing LLVMX86****.so error when you compile EOS.DLLVM_ENABLE_RTTI=ON to the cmake configuration.cd ${BUILD_TEMP}
mkdir ${BUILD_TEMP}/wasm-compiler/build -p
cd ${BUILD_TEMP}/wasm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
cd llvm/tools
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
cd ${BUILD_TEMP}/wasm-compiler/build
cmake -G "Unix Makefiles" -DLLVM_ENABLE_RTTI=ON -DLLVM_TARGETS_TO_BUILD='host' -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../llvm
sudo make -j4 install
export WASM_LLVM_CONFIG=/usr/local/bin/llvm-config
Finally, when you completed the all the dependancy compilation, you may proceed to compile the EOS source now.
cd ${BUILD_TEMP}
git clone https://github.com/eosio/eos --recursive
mkdir -p ${BUILD_TEMP}/eos/build && cd ${BUILD_TEMP}/eos/build
cmake -DBOOST_INCLUDEDIR=${BOOST_ROOT}/include/boost \
-DBOOST_LIBRARYDIR=${BOOST_ROOT}/lib ..
make -j4
Please refer to Creating and launching a single-node testnet.