2020-04-03 13:23:32 +00:00
|
|
|
|
---
|
2022-08-28 14:53:34 +00:00
|
|
|
|
slug: /en/development/build
|
2022-04-09 13:29:05 +00:00
|
|
|
|
sidebar_position: 64
|
|
|
|
|
sidebar_label: Build on Linux
|
2022-08-28 15:58:59 +00:00
|
|
|
|
title: How to Build ClickHouse on Linux
|
2022-04-09 13:29:05 +00:00
|
|
|
|
description: How to build ClickHouse on Linux
|
2020-04-03 13:23:32 +00:00
|
|
|
|
---
|
|
|
|
|
|
2020-06-03 10:19:08 +00:00
|
|
|
|
|
|
|
|
|
Supported platforms:
|
|
|
|
|
|
2023-04-19 15:55:29 +00:00
|
|
|
|
- x86_64
|
|
|
|
|
- AArch64
|
|
|
|
|
- Power9 (experimental)
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
## Building on Ubuntu
|
2020-07-20 19:12:31 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
The following tutorial is based on Ubuntu Linux.
|
|
|
|
|
With appropriate changes, it should also work on any other Linux distribution.
|
|
|
|
|
The minimum recommended Ubuntu version for development is 22.04 LTS.
|
2020-07-20 19:12:31 +00:00
|
|
|
|
|
2023-02-08 17:59:44 +00:00
|
|
|
|
### Install Prerequisites {#install-prerequisites}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2023-04-27 17:20:53 +00:00
|
|
|
|
sudo apt-get install git cmake ccache python3 ninja-build nasm yasm gawk
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
### Install and Use the Clang compiler
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
On Ubuntu/Debian you can use LLVM's automatic installation script, see [here](https://apt.llvm.org/).
|
2022-09-08 05:41:24 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
``` bash
|
2022-12-17 02:03:12 +00:00
|
|
|
|
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
|
2022-09-08 05:41:24 +00:00
|
|
|
|
```
|
|
|
|
|
|
2022-12-17 02:03:12 +00:00
|
|
|
|
Note: in case of troubles, you can also use this:
|
2020-12-30 15:10:46 +00:00
|
|
|
|
|
2021-04-22 01:20:03 +00:00
|
|
|
|
```bash
|
2022-12-17 02:03:12 +00:00
|
|
|
|
sudo apt-get install software-properties-common
|
|
|
|
|
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
2020-12-30 15:10:46 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
For other Linux distribution - check the availability of LLVM's [prebuild packages](https://releases.llvm.org/download.html).
|
2020-12-30 15:10:46 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
As of April 2023, any version of Clang >= 15 will work.
|
2023-04-24 20:14:59 +00:00
|
|
|
|
GCC as a compiler is not supported
|
2023-04-24 20:09:37 +00:00
|
|
|
|
To build with a specific Clang version:
|
2020-12-30 15:10:46 +00:00
|
|
|
|
|
|
|
|
|
``` bash
|
2023-03-18 22:45:57 +00:00
|
|
|
|
export CC=clang-16
|
|
|
|
|
export CXX=clang++-16
|
2020-12-30 15:10:46 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-07-20 19:12:31 +00:00
|
|
|
|
### Checkout ClickHouse Sources {#checkout-clickhouse-sources}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2023-02-16 17:44:01 +00:00
|
|
|
|
git clone --recursive --shallow-submodules git@github.com:ClickHouse/ClickHouse.git
|
2019-09-23 15:31:46 +00:00
|
|
|
|
```
|
2020-03-20 10:10:48 +00:00
|
|
|
|
|
2019-12-19 22:13:42 +00:00
|
|
|
|
or
|
2020-03-20 10:10:48 +00:00
|
|
|
|
|
|
|
|
|
``` bash
|
2023-02-16 17:44:01 +00:00
|
|
|
|
git clone --recursive --shallow-submodules https://github.com/ClickHouse/ClickHouse.git
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-07-20 19:12:31 +00:00
|
|
|
|
### Build ClickHouse {#build-clickhouse}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2022-05-16 11:55:42 +00:00
|
|
|
|
cd ClickHouse
|
|
|
|
|
mkdir build
|
2023-04-24 20:09:37 +00:00
|
|
|
|
cmake -S . -B build
|
|
|
|
|
cmake --build build # or: `cd build; ninja`
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-28 08:53:19 +00:00
|
|
|
|
To create an executable, run `cmake --build build --target clickhouse` (or: `cd build; ninja clickhouse`).
|
2023-04-24 20:09:37 +00:00
|
|
|
|
This will create executable `build/programs/clickhouse` which can be used with `client` or `server` arguments.
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
## Building on Any Linux {#how-to-build-clickhouse-on-any-linux}
|
2020-02-16 10:45:15 +00:00
|
|
|
|
|
2020-03-18 14:55:01 +00:00
|
|
|
|
The build requires the following components:
|
2020-02-16 10:45:15 +00:00
|
|
|
|
|
2023-04-24 20:09:37 +00:00
|
|
|
|
- Git (used to checkout the sources, not needed for the build)
|
|
|
|
|
- CMake 3.20 or newer
|
|
|
|
|
- Compiler: Clang 15 or newer
|
|
|
|
|
- Linker: lld 15 or newer
|
2023-04-19 15:55:29 +00:00
|
|
|
|
- Ninja
|
|
|
|
|
- Yasm
|
|
|
|
|
- Gawk
|
2020-02-16 10:45:15 +00:00
|
|
|
|
|
|
|
|
|
If all the components are installed, you may build in the same way as the steps above.
|
|
|
|
|
|
|
|
|
|
Example for OpenSUSE Tumbleweed:
|
2023-04-24 20:09:37 +00:00
|
|
|
|
|
2020-07-20 19:12:31 +00:00
|
|
|
|
``` bash
|
2023-04-27 17:20:53 +00:00
|
|
|
|
sudo zypper install git cmake ninja clang-c++ python lld nasm yasm gawk
|
2020-07-20 19:12:31 +00:00
|
|
|
|
git clone --recursive https://github.com/ClickHouse/ClickHouse.git
|
2023-04-24 20:09:37 +00:00
|
|
|
|
mkdir build
|
|
|
|
|
cmake -S . -B build
|
|
|
|
|
cmake --build build
|
2020-07-20 19:12:31 +00:00
|
|
|
|
```
|
2020-02-16 10:45:15 +00:00
|
|
|
|
|
2020-02-17 04:37:37 +00:00
|
|
|
|
Example for Fedora Rawhide:
|
2023-04-24 20:09:37 +00:00
|
|
|
|
|
2020-07-20 19:12:31 +00:00
|
|
|
|
``` bash
|
|
|
|
|
sudo yum update
|
2023-04-27 17:20:53 +00:00
|
|
|
|
sudo yum --nogpg install git cmake make clang python3 ccache nasm yasm gawk
|
2020-07-20 19:12:31 +00:00
|
|
|
|
git clone --recursive https://github.com/ClickHouse/ClickHouse.git
|
2023-04-24 20:09:37 +00:00
|
|
|
|
mkdir build
|
|
|
|
|
cmake -S . -B build
|
|
|
|
|
cmake --build build
|
2022-02-19 16:19:07 +00:00
|
|
|
|
```
|
2020-02-16 10:45:15 +00:00
|
|
|
|
|
2020-07-20 19:12:31 +00:00
|
|
|
|
## You Don’t Have to Build ClickHouse {#you-dont-have-to-build-clickhouse}
|
|
|
|
|
|
|
|
|
|
ClickHouse is available in pre-built binaries and packages. Binaries are portable and can be run on any Linux flavour.
|
|
|
|
|
|
2023-01-16 15:55:24 +00:00
|
|
|
|
The CI checks build the binaries on each commit to [ClickHouse](https://github.com/clickhouse/clickhouse/). To download them:
|
2023-01-16 15:07:01 +00:00
|
|
|
|
|
|
|
|
|
1. Open the [commits list](https://github.com/ClickHouse/ClickHouse/commits/master)
|
|
|
|
|
1. Choose a **Merge pull request** commit that includes the new feature, or was added after the new feature
|
|
|
|
|
1. Click the status symbol (yellow dot, red x, green check) to open the CI check list
|
|
|
|
|
1. Scroll through the list until you find **ClickHouse build check x/x artifact groups are OK**
|
|
|
|
|
1. Click **Details**
|
|
|
|
|
1. Find the type of package for your operating system that you need and download the files.
|
|
|
|
|
|
|
|
|
|
![build artifact check](images/find-build-artifact.png)
|