How to build hive on ubuntu 20.04

in #hive3 years ago (edited)

Hello,

Disclaimer: this is going to be a very technical post if you don't intend to build hive there will be little interest for you there.

I recently bought a new development server, so I went with 20.04 and realized hive did not compile on it as the default packages are creating issues. This will be fixed in due time but for now here's a post that will hopefully help some of you that are running into the same issues as I did.

Gcc / g++

ubuntu 20.04 comes with gcc/g++ 9.x, nothing wrong with that but when generating the cmake files and when trying to compile you will run into issues because of the -werror tag. One solution is to search and replace everything with -werror in the build directory after doing cmake. But it's not a great solution. We mostly need g++ but I think it's better to run the same version of gcc and g++.

So we are going to use gcc/g++ 7.

installing it:
sudo apt-get install gcc-7 g++-7

Adding them as the current alternatives:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 10

You can also add gcc/g++ 9 as other alternatives so you can easily switch between the versions, but I am fine with just using v7 so I did not include that in the tutorial

you can test your config by doing
gcc -v
and
g++ -v

you should see something like:
gcc version 7.5.0 (Ubuntu 7.5.0-6ubuntu2)

Boost

Then comes boost, after 1.7 they introduced a breaking change in the way they version the library, so cmake won't recognize it, by default you have boost 1.71, we are going to uninstall it and install 1.67 instead.

you may not have the same boost version so first find which boost version you have:

dpkg -S /usr/include/boost/version.hpp

you'll see something like

libboost1.71-dev:amd64: /usr/include/boost/version.hpp

uninstall it with

sudo apt-get --purge remove libboost1.71-dev

Then install boost 1.67:

wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz (you can find this link here: https://www.boost.org/users/history/version_1_67_0.html)

once you have the file you just have to install it:

tar xf boost_1_67_0.tar.gz
cd boost_1_67_0
# get the no of cpucores to make faster
cpuCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
echo "Available CPU cores: "$cpuCores
./bootstrap.sh  # this will generate ./b2
sudo ./b2 --with=all -j $cpuCores install

and that's it ! You should be good to go :)

If you want to dig here are a few sources I used:

https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version
https://stackoverflow.com/questions/8430332/uninstall-boost-and-install-another-version

Sort:  

It might be a good idea to install Boost into a different directory, not the default /usr/local.

Personally I like to keep manually installed libraries separated from the rest of the system. Mixing things up can lead to a very messy dependency-hell.

During the last HardFork because I took the opportunity to change server (to have one main and one backup/sandbox) I tried to install ubuntu 20.04 but I quickly came back to a version 18.04 when I saw all the compiling errors. I wasn't as brave as you were 🤣 so thank you for this documentation which will help me on my next attempt 😉


@mintrawa: Witness FR - Gen X - Geek 🤓 Gamer 🎮 traveler ⛩️
Don't miss the Hive Power UP Day! more info here

Hey @howo!
A bit of topic here... how can we check the conversion from Hive to HBD of the funds in the DHF ... @hive.fund account. I remember you posted about a 5 years conversion. Is this live? What is the mechanics of converting. How much Hive/HBD is converted daily?

It is live, We convert 0.05% of the hive on the @hive.fund every day. It only happens once per day so it's not very visible when looking at the transactions, but here's yesterday's execution:

image.png

Hey thanks!
How does the HBD in the hive.fund affects the debt ratio?

Nope ! This was also a change I made in hf24 :)

@howo,
Didnt try yet! Thanks for the guide!
$tangent

Cheers~


Congratulations, @theguruasia You Successfully Trended The Post Shared By @howo.
You Utilized 3/3 Daily Summon Bot Calls.

TAN Current Market Price : 2.000 HIVE


Congratulations @howo, You Earned 1.078 TAN & Curators Made 0.754 TAN.

tangent.token


Join CORE / VAULT Token Discord Channel or Trade TANGENT Token
TAN Current Market Price : 2.010 HIVE