How to build hive on ubuntu 20.04

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

10 Comments