> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Compile StarRocks on Ubuntu

> How to compile StarRocks from source on Ubuntu.

This topic describes how to compile StarRocks on the Ubuntu operating system. StarRocks supports compilation on both x86\_64 and AArch64 architectures.

**Note**

Build StarRocks v4.1 and earlier on Ubuntu 22.04, and StarRocks v4.2 and later on Ubuntu 24.04.

## Prerequisites

### Install Dependencies

Run the following commands to install necessary dependencies:

```bash theme={null}
sudo apt update
```

```bash theme={null}
sudo apt install build-essential automake bison byacc ccache flex libiberty-dev libtool maven zip python3 python-is-python3 bzip2 -y
```

### Install Compiler

If you are using Ubuntu 22.04 or later, run the following command to install the tools and compilers:

```bash theme={null}
sudo apt install cmake gcc g++ openjdk-17-jdk -y
```

If you are using an Ubuntu version earlier than 22.04, run the following commands to check the versions of tools and compilers:

1. Check GCC/G++ versions:

   ```bash theme={null}
   gcc --version
   g++ --version
   ```

   GCC/G++ versions must be 10.3 or later. If you are using earlier versions, [click here to install GCC/G++](https://gcc.gnu.org/releases.html).

2. Check JDK version:

   ```bash theme={null}
   java --version
   ```

   OpenJDK version must be 17 or later. If you are using an earlier version, [click here to install OpenJDK](https://openjdk.org/install).

3. Check CMake version:

   ```bash theme={null}
   cmake --version
   ```

   CMake version must be 3.20.1 or later. If you are using an earlier version, [click here to install CMake](https://cmake.org/download).

## Compile StarRocks

### Download Source Code

Run the following command to clone the StarRocks repository and navigate into the directory:

```bash theme={null}
git clone https://github.com/StarRocks/starrocks.git
cd starrocks
```

### Build StarRocks

Run the following command to start the compilation:

```bash theme={null}
./build.sh
```

The default compilation parallelism is equal to **CPU core count/4**. Assuming you have 32 CPU cores, the default parallelism is 8.

If you want to adjust the parallelism, you can specify the number of CPU cores to be used for compilation via `-j` in the command line.

The following example uses 24 CPU cores for compilation:

```bash theme={null}
./build.sh -j 24
```

## FAQ

Q-1: Building `aws_cpp_sdk` fails on Ubuntu 20.04 with the error "Error: undefined reference to pthread\_create". How can I resolve this?

A: This error occurs due to a lower version of CMake. Please upgrade CMake to version 3.20.1 or above.

Q-2: Building StarRocks fails on Ubuntu 24.04 or GCC 12+ with strict warning errors. How can I resolve this?

A: To prevent build failures in third-party libraries, export the following flag before building:

```bash theme={null}
export DISABLE_WARNING_AS_ERROR=1
./build.sh
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.