Build and setup decent node for decentgo website on Debian server

Most of the information actually can be decoded from travis build configuration file which is intended for Ubuntu 14 travis servers.

https://github.com/DECENTfoundation/DECENT-Network/blob/master/.travis.yml.

Below is the manual for Debian server.

Install Prerequisites

 sudo apt-get update -qq && sudo apt-get install -qq build-essential autotools-dev automake autoconf libtool make cmake checkinstall realpath gcc g++ clang flex bison doxygen gettext git qt5-default libqt5svg5-dev libreadline-dev libcrypto++-dev libgmp-dev libdb-dev libdb++-dev libssl-dev libncurses5-dev libboost-all-dev libcurl4-openssl-dev python-dev libicu-dev libbz2-dev

Create and choose current directory

 mkdir /data/build
 cd /data/build

Build cmake

Do this step only for the first time. In case of consecutive times cmake will be there already.

 wget && tar xf cmake-3.7.2.tar.gz && mkdir cmake-3.7.2_prefix && cd cmake-3.7.2 && https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz CMAKE_ROOT=$(realpath ../cmake-3.7.2_prefix)
 ./configure --prefix=$CMAKE_ROOT && make && make install && cd ..
 export PATH=$CMAKE_ROOT/bin:$PATH

Have cmake bin part of PATH environment

In case of doing this consecutive times, there is a need to do the following step only.

 CMAKE_ROOT=/data/build/cmake-3.7.2_prefix
 export PATH=$CMAKE_ROOT/bin:$PATH

Build Boost

Do this step only for the first time. In case of consecutive times boost will be there already.

 wget && tar xf boost_1_60_0.tar.gz && mkdir boost-1.60.0_prefix && https://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz cd boost_1_60_0 && export BOOST_ROOT=$(realpath ../boost-1.60.0_prefix)
 ./bootstrap.sh --prefix=$BOOST_ROOT && ./b2 install && cd ..

Have boost root environment variable

In case of doing this consecutive times, there is a need to do the following step only.

 export BOOST_ROOT=/data/build/boost-1.60.0_prefix

Get DECENT sources

 cd /data/build
 git clone https://github.com/DECENTfoundation/DECENT-Network
 cd DECENT-Network
 git submodule update --init --recursive
 git checkout develop
 git pull

I usually make sure that develop branch is not corrupted and I am using that one. All setups for DECENT-GO (live server, stage server) I have done by using develop branch. As of 14-08-2017 develop is fine to use.

Do custom modification to code

Edit the file /data/build/DECENT-Network/libraries/wallet/wallet.cpp, find the commented line

 //#define DECENTGO, 

uncomment it to have the following

  #define DECENTGO

and save the file.

Build DECENT

 mkdir /data/build/DECENT-Network-build
 cd /data/build/DECENT-Network-build
 cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release ../DECENT-Network
 make

Build DECENT from source

Installing prerequisites in Linux

For Ubuntu 16.04 LTS (for extra actions needed for 14.04 LTS, 14.10, or 16.10, see notes below), execute in the console:

 $ sudo apt-get update
 $ sudo apt-get install build-essential autotools-dev automake autoconf libtool make cmake checkinstall realpath gcc g++ flex bison doxygen gettext git qt5-default libqt5svg5-dev libreadline-dev libcrypto++-dev libgmp-dev libdb-dev libdb++-dev libssl-dev libncurses5-dev libboost-all-dev libcurl4-openssl-dev python-dev libicu-dev libbz2-dev

(Ubuntu 16.10 only) Note, that the default version of Boost installed in Ubuntu 16.10 is too high and not supported. In order to install the supported one, in addition to the common commands above, execute the following commands in the console:

 # Uninstall the default Boost and install Boost 1.60.0
 $ sudo apt-get remove libboost-all-dev
 $ sudo apt-get autoremove
 $ sudo apt-get install libboost1.60-all-dev

(Ubuntu 14.04 LTS and 14.10 only; and only boost part for Ubuntu 16.04 LTS case). Note that the default versions of GCC, CMake and Boost installed in Ubuntu 14.04 LTS or 14.10 are too old and not supported. In order to install and use the supported ones, in addition to the common commands above, execute the following commands in the console (in the same shell session, where you are going to build Decent itself):

 # Install GCC5
 $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
 $ sudo apt-get update
 $ sudo apt-get install gcc-5 g++-5
 # Now use gcc-5 and g++-5 as C and C++ compilers.
 $ export CC=gcc-5
 $ export CXX=g++-5

 # Download and build CMake 3.7.2
 $ mkdir -p ~/dev/DECENTfoundation/DECENT-Network-third-party
 $ cd ~/dev/DECENTfoundation/DECENT-Network-third-party
 $ rm -rf cmake-3.7.2*
 $ wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
 </file><code>
 $ tar xvf cmake-3.7.2.tar.gz
 $ mkdir cmake-3.7.2_prefix
 $ cd cmake-3.7.2
 $ CMAKE_ROOT=$(realpath ../cmake-3.7.2_prefix)
 $ ./configure --prefix=$CMAKE_ROOT
 $ make
 $ make install
 $ cd ..
 $ rm -rf cmake-3.7.2 cmake-3.7.2.tar.gz
 $ export PATH=$CMAKE_ROOT/bin:$PATH

 # Download and build Boost 1.60.0
 $ mkdir -p ~/dev/DECENTfoundation/DECENT-Network-third-party
 $ cd ~/dev/DECENTfoundation/DECENT-Network-third-party
 $ rm -rf boost_1_60_0* boost-1.60.0*
 $ wget https://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz
 </file><code>
 $ tar xvf boost_1_60_0.tar.gz
 $ mkdir boost-1.60.0_prefix
 $ cd boost_1_60_0
 $ export BOOST_ROOT=$(realpath ../boost-1.60.0_prefix)
 $ ./bootstrap.sh --prefix=$BOOST_ROOT
 $ ./b2 install
 $ cd ..
 $ rm -rf boost_1_60_0 boost_1_60_0.tar.gz

At this point, $CC and $CXX should be set to your compilers, cmake command should be picked up from $CMAKE_ROOT/bin, and CMake configure should find the Boost distribution in the exported $BOOST_ROOT.

For Fedora 24 or later execute in the console:

 $ sudo dnf clean metadata
 $ sudo dnf install automake autoconf libtool make cmake gcc flex bison doxygen gettext-devel git qt5-qtbase-devel qt5-qtsvg-devel readline-devel cryptopp-devel gmp-devel libdb-devel libdb-cxx-devel openssl-devel libcurl-devel ncurses-devel boost-devel boost-static python-devel libicu-devel bzip2-devel

Installing prerequisites in macOS

Then, execute in the console:

 $ brew doctor
 $ brew tap homebrew/versions
 $ brew update
 $ brew install automake autoconf libtool cmake berkeley-db [email protected] qt5 cryptopp doxygen byacc flex gettext git pbc gmp ipfs openssl readline

Obtaining the sources, building, and installing Decent in *nix (macOS or Linux)

After all the prerequisites are installed, execute the following commands in console, in order to clone the repo, build and install/stage Decent:

 # Clone the repo.
 $ mkdir -p ~/dev/DECENTfoundation
 $ cd ~/dev/DECENTfoundation
 $ git clone [email protected]:DECENTfoundation/DECENT-Network.git
 $ cd DECENT-Network
 $ git submodule update --init --recursive

 # Build and install Decent.
 $ mkdir -p ~/dev/DECENTfoundation/DECENT-Network-build
 $ cd ~/dev/DECENTfoundation/DECENT-Network-build
 $ cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ~/dev/DECENTfoundation/DECENT-Network
 $ cmake --build . --target all -- -j -l 3.0
 $ cmake --build . --target install

Note that in case of "Unix Makefiles" CMake generator, the last two commands are equivalent to:

 $ make -j -l 3.0
 $ make install

By this time you should have Decent files installed at ~/dev/DECENTfoundation/DECENT-Network-build/artifacts/prefix directory. You can specify any other custom install prefix for cmake during the initial configuration, for example, by adding -D CMAKE_INSTALL_PREFIX=~/dev/DECENTfoundation/DECENT-Network-prefix to the command line.

You can use any path instead of ~/dev/DECENTfoundation in the steps above.

You can use Xcode, or any other CMake generator, and then, if it is an IDE generator, instead of building and installing via cmake in terminal, open the generated project/solution file in the corresponding IDE and perform ALL_BUILD and INSTALL (or install) actions from there.

Installing prerequisites, obtaining the sources, building, and installing DECENT in Windows

You need Microsoft Visual Studio 2015 with Update 3. MS VS 2017 should be also ok, but currently we are still using MS VS 2015. You need CMake 3.8.1. Windows build uses the same common libraries as Linux/Mac. The difference is only in GMP library. Install Mpir-3.0.0 instead of GMP and build the library for generic target (under build.vc14lib_mpir_gc or build.vc14dll_mpir_gc). It generates gmp.h and mpir.lib which must be used instead of gmp.lib, used on Linux/Mac.

Because the CMake on Windows cannot rely on installed development packages with headers and libraries as on Linux, you must run CMake command line which specifies where your libraries are installed. After pulling sources from git set command line current directory to root of sources and run CMake from there. The following command line is used in our environment to generate all needed MS VS 2015 projects:

 cmake -DCMAKE_CXX_FLAGS="/DWIN32 /D_WIN32_WINNT=0x0601; /IC:/Projects" -DBOOST_ROOT=c:/local/boost_1_60_0 -DBoost_COMPILER=-vc140 -DBOOST_INCLUDEDIR=c:/local/boost_1_60_0/boost -DBOOST_LIBRARYDIR=c:/local/boost_1_60_0/lib64-msvc-14.0 -DCMAKE_PREFIX_PATH=c:/Projects -DCMAKE_INCLUDE_PATH=c:/Projects -DCMAKE_LIBRARY_PATH=C:/Projects/cryptopp/x64/DLL_Output/Release -DOPENSSL_ROOT_DIR=c:/Projects/OpenSSLx64 -DZLIB_LIBRARY=C:\Projects\zlib123\projects\visualc6\Win64_LIB_Release\zlib.lib -DZLIB_INCLUDE_DIR=c:/Projects/zlib123 -DCURL_LIBRARY="C:/Projects/cUrl/build/Win64/VC14/DLL Release - DLL Windows SSPI/libcurl.lib" -DCURL_INCLUDE_DIR=c:/Projects/cUrl/include -DGENERATEDGMP=C:/Projects/mpir-3.0.0/build.vc14/lib_mpir_gc/x64/Release -DPBCROOT=C:\Projects\pbc -DQt5Core_DIR=C:\Qt2\5.8\msvc2015_64\lib\cmake\Qt5Core -DQt5Widgets_DIR=C:\Qt2\5.8\msvc2015_64\lib\cmake\Qt5Widgets -DQt5Svg_DIR=C:\Qt2\5.8\msvc2015_64\lib\cmake\Qt5Svg -DQt5Core_DIR=C:\Qt2\5.8\msvc2015_64\lib\cmake\Qt5Core -DQt5Widgets_DIR=C:\Qt2\5.8\msvc2015_64\lib\cmake\Qt5Widgets -G "Visual Studio 14 2015 Win64" .

In above example C:Projects is the root for all extracted libraries with exception of boost which was installed to c:local.

CMake generates all MS VS 2015 project files. First try to build decentd project, which builds all dependencies and decentd.exe. Then build cli_wallet which builds cli_wallet.exe and finally build decent project which builds GUI.