Skip to main content

Compile Apache Doris Directly on Linux

This document describes how to compile Apache Doris directly on Linux (using Ubuntu 24.04 or later as the example), without using a Docker image or the LDB Toolchain.

Target Audience, Pros, and Cons

DimensionDescription
Target audienceDevelopers on a newer distribution (such as Ubuntu 24.04+) who want to use the system's bundled GCC
ProsFewest steps; install dependencies directly through the system package manager
ConsOlder distributions may fail to compile because GCC or glibc is too old. In that case, use the LDB Toolchain instead

Environment Requirements

ComponentVersion requirement
Operating systemUbuntu 24.04+ (or an equivalent version of another distribution)
JDK8+ (for version 2.1 and earlier); 17 (for version 3.0 and later, or the master branch)
GCC10+
Python2.7+
Apache Maven3.5+
CMake3.19.2+
Bison3.0+

1. Install JDK

Choose the JDK based on the target Doris version:

# To compile Doris 2.1 or earlier, install JDK 8
sudo apt install openjdk-8-jdk

# To compile Doris 3.0 or later, or the master branch, install JDK 17
sudo apt install openjdk-17-jdk

2. Install System Dependencies

sudo apt install build-essential maven cmake byacc flex automake libtool-bin bison binutils-dev libiberty-dev zip unzip libncurses5-dev curl git ninja-build python
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt update
sudo apt install gcc-10 g++-10
sudo apt-get install autoconf automake libtool autopoint

3. Check Whether the CPU Supports AVX2

cat /proc/cpuinfo | grep avx2

A non-empty output means the CPU supports AVX2, and you can use the default compile options. Otherwise, append USE_AVX2=0 to the build command.

4. Run the Build

# Default build, producing AVX2-enabled artifacts
sh build.sh

# When the CPU does not support AVX2, append USE_AVX2=0
USE_AVX2=0 sh build.sh

# Build a Debug version of BE
BUILD_TYPE=Debug sh build.sh

5. Locate the Build Artifacts

After the build completes, the artifacts are located under output/ in the source root directory.

FAQ

Q1: Can older versions of Ubuntu or CentOS compile directly?

Older distributions usually ship with versions of GCC and glibc that are too old. Use the LDB Toolchain or the Docker image instead.

Q2: The build reports AVX2 not supported.

The CPU does not support the AVX2 instruction set. Rerun with USE_AVX2=0 sh build.sh, and download the no-avx2 series of prebuilt third-party libraries.

Q3: The build fails with Too many open files.

Raise the per-process file handle limit with ulimit -n 65536, or configure it permanently in /etc/security/limits.conf.

Q4: The build is killed midway due to insufficient memory.

The message ninja failed with: signal: killed usually indicates OOM. Use a machine with at least 16 GB of memory, or reduce the parallelism (the -j parameter).