Build libhipcxx from source#

2026-10-02

4 min read time

Applies to Linux and Windows

To build libhipcxx as part of the ROCm Core SDK, see Install AMD ROCm. TheRock is the recommended way to build ROCm components from source.

Alternatively, you can build libhipcxx standalone using the following instructions.

libhipcxx build prerequisites#

On Linux, ROCm must be installed before libhipcxx is built.

libhipcxx has the following prerequisites:

  • CMake version 3.21 or higher

  • hipcc

  • A C++17 or C++20 host toolchain

libhipcxx has these additional prerequisites to build and run the tests:

  • LLVM version 18.1.8 or higher. Only its CMake modules are required.

  • lit version 18.1.8

  • Ninja

  • sccache

Get the libhipcxx source code#

The libhipcxx source code is available from the libhipcxx GitHub repository. Clone the repository:

git clone https://github.com/ROCm/libhipcxx.git
cd libhipcxx

Then use git checkout to check out the branch you need.

The amd-develop branch is intended for users who want to preview new features or contribute to the libhipcxx code base.

If you don’t intend to contribute to the libhipcxx code base and won’t be previewing features, use a branch that matches the version of ROCm installed on your system.

Build with CMake#

Set CXX to hipcc and set CMAKE_CXX_COMPILER to hipcc’s absolute path. For example:

CXX=hipcc
CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc

Create the build directory under the libhipcxx root directory, then change directory to the build directory:

mkdir build
cd build

Generate the libhipcxx build files using the cmake command:

cmake -GNinja ../. [-D<OPTION1=VALUE1> [-D<OPTION2=VALUE2>] ...]

The build options are:

  • LIBHIPCXX_TEST_WITH_HIPRTC: Set this to ON to build and run the tests with HIPRTC support. Default is OFF.

  • LIBCUDACXX_ENABLE_LIBCUDACXX_TESTS: Set this to OFF to skip configuring the lit test suite. Default is ON.

  • libhipcxx_ENABLE_INSTALL_RULES: Set this to OFF to skip generating install rules. Default is ON when libhipcxx is the top-level project.

  • libhipcxx_ENABLE_CODEGEN: Set this to ON to enable the atomics backend code generation and its tests. Default is OFF.

  • CMAKE_HIP_ARCHITECTURES: Set this to the GPU architectures to build for, for example gfx942. AMDGPU_TARGETS and GPU_TARGETS are also accepted.

  • CMAKE_INSTALL_PREFIX: Set this to the installation directory. For example, use /opt/rocm to install alongside ROCm.

Build libhipcxx using the generated build files:

ninja

After you’ve built libhipcxx, you can optionally generate TGZ, ZIP, and DEB packages:

cpack .

To generate an RPM package, run:

cpack -G RPM .

Finally, install libhipcxx:

ninja install