Build libhipcxx from source#
2026-10-02
4 min read time
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:
libhipcxx has these additional prerequisites to build and run the tests:
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 toONto build and run the tests with HIPRTC support. Default isOFF.LIBCUDACXX_ENABLE_LIBCUDACXX_TESTS: Set this toOFFto skip configuring the lit test suite. Default isON.libhipcxx_ENABLE_INSTALL_RULES: Set this toOFFto skip generating install rules. Default isONwhen libhipcxx is the top-level project.libhipcxx_ENABLE_CODEGEN: Set this toONto enable the atomics backend code generation and its tests. Default isOFF.CMAKE_HIP_ARCHITECTURES: Set this to the GPU architectures to build for, for examplegfx942.AMDGPU_TARGETSandGPU_TARGETSare also accepted.CMAKE_INSTALL_PREFIX: Set this to the installation directory. For example, use/opt/rocmto 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