Why did we do it?
We started working on creating a build for ClickHouse on WSL with the aim of becoming more familiar with ClickHouse. As an organization focusing on ClickHouse optimization at every level, this is obviously a necessity for us as well. And so the endeavour began.
The machine I was working on is a laptop with 8GB memory and AMD Ryzen 3 processor, running Windows 10. The WSL system was Ubuntu 20.04. The instructions for creating the build which I followed can be found at this link.
The instructions and commands to be followed are listed in the article given above, and I followed them to the letter. So it would be no surprise to the reader that I chose not to use GCC and went ahead with using Clang for the build, since the article recommends strongly against using it. But there was another reason why I didn’t bother using GCC, which was simply that GCC did not come pre-installed on my WSL Ubuntu. I could have installed it with a simple “sudo apt install”, but getting the specific version required for building ClickHouse (GCC 11 or above) might still be hard to get. If I ran out of all other options, I’d have to build GCC from source also, which was something I didn’t fancy wasting my time on when a huge task such as building ClickHouse was at hand.
The Build Process
You need the following tools for building ClickHouse from source:
- The latest version of
All of the above except for Clang can be downloaded with the following command:
sudo apt-get install git cmake python ninja-build
To download Clang, you can use the following command on Ubuntu and Debian WSL images (This might work for other Debian-based Linux distributions also, but that needs to be verified):
sudo bash -c "$(wget -O -
This downloads the Clang compiler into your system, and you can set the default Clang version to be used in the terminal as follows:
We need to use Clang-14 or above for creating this build, since it is required by ClickHouse.
The next step is to clone the ClickHouse source code onto your machine. Take care to clone the repo recursively, if you are typing it out by hand, so that all the dependencies can be cloned along with the repository. This command achieves that:
git clone --recursive email@example.com:ClickHouse/ClickHouse.git
Alternatively, you could also use HTTPS to fetch the repository, with a minor change to the above command:
git clone --recursive
It could take you a comparatively long time to clone the ClickHouse repo and its dependencies. On my machine with its humble configuration, it took nearly an entire day.
Once you have cloned the ClickHouse repository, run the following commands one-after-the-other for the build to start:
First you go to the ClickHouse source directory:
Next you create a build directory in the ClickHouse source root directory and enter it:
mkdir build && cd build
Then run CMake to create the build files in their appropriate locations:
Finally you can build the ClickHouse source with Ninja build:
Once you execute these commands, the build will be ready. Be warned, it could take a long time! Happy coding.