# How to Install Abseil C++: CMake, Bazel, and Conan Setup Guide

> Learn how to install Abseil C++ using CMake, Bazel, or Conan. Our guide simplifies setup for CMake add_subdirectory, find_package, Bazel http_archive, and Conanfile.py integration.

- Repository: [Abseil/abseil-cpp](https://github.com/abseil/abseil-cpp)
- Tags: how-to-guide
- Published: 2026-07-15

---

**Abseil C++ can be integrated into your project using CMake via `add_subdirectory` or `find_package`, Bazel through `http_archive` in your WORKSPACE file, or Conan using the provided [`conanfile.py`](https://github.com/abseil/abseil-cpp/blob/main/conanfile.py), with system package managers offering pre-built alternatives for Linux distributions.**

The `abseil/abseil-cpp` repository provides several installation methods to accommodate different build systems and workflows. Whether you prefer CMake's widespread compatibility, Bazel's native integration, or Conan's package management, the library offers documented paths in [`CMake/README.md`](https://github.com/abseil/abseil-cpp/blob/main/CMake/README.md), [`README.md`](https://github.com/abseil/abseil-cpp/blob/main/README.md), and [`conanfile.py`](https://github.com/abseil/abseil-cpp/blob/main/conanfile.py) for each approach.

## CMake Installation (Recommended for Most Projects)

CMake is the most portable option for incorporating Abseil into existing C++ projects. The [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt) at the repository root provides targets that can be consumed either as a subdirectory or as an installed package.

### Adding Abseil as a Subdirectory

Clone the repository and include it directly in your build tree. This method avoids system-wide installation and ensures ABI compatibility.

```bash
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp

```

In your project's [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt), add the Abseil source tree and link the specific targets you need:

```cmake
cmake_minimum_required(VERSION 3.16)
project(my_project)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(path/to/abseil-cpp)

add_executable(my_app src/main.cpp)
target_link_libraries(my_app
    absl::base
    absl::strings
    absl::synchronization)

```

### Installing Abseil System-Wide

For environments where multiple projects share the same Abseil installation, enable the install step using the `ABSL_ENABLE_INSTALL` option defined in [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt).

```bash
cmake -B build -S . -DABSL_ENABLE_INSTALL=ON
cmake --build build
cmake --install build  # Installs to /usr/local by default

```

After installation, downstream projects can locate the library using standard CMake patterns:

```cmake
find_package(absl REQUIRED)
target_link_libraries(my_target absl::base absl::strings)

```

## Bazel Installation (Official Build System)

Bazel is the official build system for Abseil and provides the fastest integration for Google-centric toolchains. Add the following to your `WORKSPACE` file to fetch the repository:

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "abseil_cpp",
    urls = ["https://github.com/abseil/abseil-cpp/archive/refs/heads/master.zip"],
    strip_prefix = "abseil-cpp-master",
    sha256 = "<computed-sha256>",
)

```

In your `BUILD` files, declare dependencies on specific Abseil modules:

```python
cc_binary(
    name = "my_binary",
    srcs = ["main.cc"],
    deps = [
        "@abseil_cpp//absl:base",
        "@abseil_cpp//absl:strings",
        "@abseil_cpp//absl:synchronization",
    ],
)

```

Run your build with:

```bash
bazel build //:my_binary

```

The `ci/` directory contains reference scripts demonstrating Bazel builds across various platforms.

## Conan Installation (Package Manager)

For projects already using Conan, the repository includes a [`conanfile.py`](https://github.com/abseil/abseil-cpp/blob/main/conanfile.py) recipe for packaging Abseil.

Create the package from the repository root:

```bash
conan create . abseil/2024.0

```

Consume it in your [`conanfile.txt`](https://github.com/abseil/abseil-cpp/blob/main/conanfile.txt):

```text
[requires]
abseil/2024.0

[generators]
cmake

```

Then install dependencies and proceed with your standard CMake workflow:

```bash
conan install .
cmake -B build .
cmake --build build

```

## System Package Managers

Some Linux distributions ship pre-built Abseil packages. For example, Debian and Ubuntu users can install via:

```bash
sudo apt install libabsl-dev

```

This method provides the quickest installation but may lag behind the upstream repository in version availability.

## Summary

- **CMake** offers two paths: `add_subdirectory` for embedded builds or `ABSL_ENABLE_INSTALL` with `find_package` for system-wide installation, documented in [`CMake/README.md`](https://github.com/abseil/abseil-cpp/blob/main/CMake/README.md).
- **Bazel** uses `http_archive` in your `WORKSPACE` file and `deps` in `BUILD` files, providing the most native integration as described in [`README.md`](https://github.com/abseil/abseil-cpp/blob/main/README.md).
- **Conan** leverages the provided [`conanfile.py`](https://github.com/abseil/abseil-cpp/blob/main/conanfile.py) to create versioned packages consumable by any CMake-based project.
- **System packages** like `libabsl-dev` provide immediate availability but potentially older versions.

## Frequently Asked Questions

### Can I install Abseil C++ using apt or yum?

Yes. Debian and Ubuntu provide `libabsl-dev` through the apt repository. Red Hat-based distributions may package Abseil in EPEL or similar repositories. However, distribution packages often trail the GitHub repository by several releases, so check the version against your requirements.

### What is the minimum C++ standard required for Abseil?

Abseil requires **C++17** or later. When using CMake, ensure you set `CMAKE_CXX_STANDARD` to 17 or higher and enable `CMAKE_CXX_STANDARD_REQUIRED` to enforce compliance, as the library uses modern C++ features extensively.

### How do I link specific Abseil targets in CMake?

Abseil provides fine-grained targets following the `absl::` namespace convention. In your `target_link_libraries()` call, specify only the modules you need, such as `absl::base`, `absl::strings`, `absl::synchronization`, or `absl::flat_hash_map`. This selective linking reduces binary size and dependency overhead compared to linking a monolithic library.

### Is Bazel required to use Abseil C++?

No. While Bazel is the official build system used internally at Google and referenced in the quick-start documentation, CMake is fully supported and widely used in the open-source community. The [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt) and [`CMake/README.md`](https://github.com/abseil/abseil-cpp/blob/main/CMake/README.md) files provide comprehensive instructions for non-Bazel environments.