How to Build ClickHouse for Development

The following tutorial is based on the Ubuntu Linux system.
With appropriate changes, it should also work on any other Linux distribution.
Supported platforms: x86_64 and AArch64. Support for Power9 is experimental.

Install Git, CMake, Python and Ninja

  1. $ sudo apt-get install git cmake python ninja-build

Or cmake3 instead of cmake on older systems.

Install GCC 9

There are several ways to do this.

Install from a PPA Package

  1. $ sudo apt-get install software-properties-common
  2. $ sudo apt-add-repository ppa:ubuntu-toolchain-r/test
  3. $ sudo apt-get update
  4. $ sudo apt-get install gcc-9 g++-9

Install from Sources

Look at utils/ci/build-gcc-from-sources.sh

Use GCC 9 for Builds

  1. $ export CC=gcc-9
  2. $ export CXX=g++-9

Checkout ClickHouse Sources

  1. $ git clone --recursive [email protected]:ClickHouse/ClickHouse.git

or

  1. $ git clone --recursive https://github.com/ClickHouse/ClickHouse.git

Build ClickHouse

  1. $ cd ClickHouse
  2. $ mkdir build
  3. $ cd build
  4. $ cmake ..
  5. $ ninja
  6. $ cd ..

To create an executable, run ninja clickhouse.
This will create the dbms/programs/clickhouse executable, which can be used with client or server arguments.

How to Build ClickHouse on Any Linux

The build requires the following componenets:

  • Git (is used only to checkout the sources, it’s not needed for build)
  • CMake 3.10 or newer
  • Ninja (recommended) or Make
  • C++ compiler: gcc 9 or clang 8 or newer
  • Linker: lld or gold (the classic GNU ld won’t work)
  • Python (is only used inside LLVM build and it is optional)

If all the components are installed, you may build in the same way as the steps above.

Example for Ubuntu Eoan:

  1. sudo apt update
  2. sudo apt install git cmake ninja-build g++ python
  3. git clone --recursive https://github.com/ClickHouse/ClickHouse.git
  4. mkdir build && cd build
  5. cmake ../ClickHouse
  6. ninja

Example for OpenSUSE Tumbleweed:

  1. sudo zypper install git cmake ninja gcc-c++ python lld
  2. git clone --recursive https://github.com/ClickHouse/ClickHouse.git
  3. mkdir build && cd build
  4. cmake ../ClickHouse
  5. ninja

Example for Fedora Rawhide:

  1. sudo yum update
  2. yum --nogpg install git cmake make gcc-c++ python2
  3. git clone --recursive https://github.com/ClickHouse/ClickHouse.git
  4. mkdir build && cd build
  5. cmake ../ClickHouse
  6. make -j $(nproc)

You Don’t Have to Build ClickHouse

ClickHouse is available in pre-built binaries and packages. Binaries are portable and can be run on any Linux flavour.

They are build for stable, prestable and testing releases as long as for every commit to master and for every pull request.

To find the most fresh build from master, go to commits page, click on the first green check mark or red cross near commit, and click to the “Details” link right after “ClickHouse Build Check”.

How to Build ClickHouse Debian Package

Install Git and Pbuilder

  1. $ sudo apt-get update
  2. $ sudo apt-get install git python pbuilder debhelper lsb-release fakeroot sudo debian-archive-keyring debian-keyring

Checkout ClickHouse Sources

  1. $ git clone --recursive --branch master https://github.com/ClickHouse/ClickHouse.git
  2. $ cd ClickHouse

Run Release Script

  1. $ ./release