Getting Started
This page covers what you need to build RTXUI, how to add it to a CMake project, and how to build the repository itself.
Requirements
- A C++23 compiler. C++23 is required to build and use RTXUI. A compiler with C++26 reflection also lets loops read the fields of your own structs without a
Fields()function (see Loops). - Linux, macOS or Windows. On Windows, RTXUI drives the console through its virtual terminal mode, from Windows 10 version 1809. It has been checked by hand in the console window itself (conhost), whose font lacks some glyphs RTXUI replaces (see Glyphs the terminal lacks), in Windows Terminal, WezTerm, Alacritty, mintty (Git Bash) and the VS Code terminal. MSVC, clang-cl and MinGW-w64 GCC are tested. RTXUI also targets the browser through Emscripten / WebAssembly.
- CMake 3.24 or newer.
- Ninja (optional, faster builds than Make).
On Debian or Ubuntu:
sudo apt install cmake ninja-build g++-14Select the compiler per build rather than changing system defaults — pass it to CMake explicitly:
CC=gcc-14 CXX=g++-14 cmake -B build -G Ninja(For Clang, install it from your distribution or apt.llvm.org and set CC=clang CXX=clang++ the same way.)
Adding RTXUI to your project
With FetchContent
The simplest integration downloads RTXUI at configure time:
cmake_minimum_required(VERSION 3.24)
project(my_app LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(FetchContent)
FetchContent_Declare(
rtxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/RTXUI.git
GIT_TAG v0.1.1 # A release tag, or main for the latest.
)
FetchContent_MakeAvailable(rtxui)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE rtxui)With an installed package
If RTXUI has been installed (cmake --install), consume it with find_package:
find_package(rtxui REQUIRED)
target_link_libraries(my_app PRIVATE rtxui::rtxui)Outside CMake (Meson, Makefiles, ...), the install also provides rtxui.pc for pkg-config:
c++ -std=c++23 main.cpp $(pkg-config --cflags --libs rtxui) -o my_appWith Bazel
RTXUI is a Bazel module. It is not in the Bazel Central Registry yet, so point MODULE.bazel at the repository:
bazel_dep(name = "rtxui")
git_override(
module_name = "rtxui",
remote = "https://github.com/ArthurSonzogni/RTXUI.git",
tag = "v0.1.1",
)Then depend on @rtxui and compile as C++23:
cc_binary(
name = "my_app",
srcs = ["main.cpp"],
copts = ["-std=c++23"],
deps = ["@rtxui"],
)First program
Create main.cpp:
#include <rtxui/rtxui.hpp>
class App : public rtxui::Component<App> {
public:
std::string_view view = R"html(
<div>Hello from RTXUI.</div>
)html";
};
int main() {
auto app = rtxui::Ref<App>::New();
rtxui::Screen screen(app);
screen.Loop();
}Configure, build, and run:
CC=gcc-14 CXX=g++-14 cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/my_appPress Ctrl-C to quit. The Hello World walkthrough explains each line and adds styling.
Building the repository
To work on RTXUI itself, or to run its examples and tests:
git clone https://github.com/ArthurSonzogni/RTXUI.git
cd RTXUI
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DRTXUI_BUILD_TESTS=ON -DRTXUI_BUILD_EXAMPLES=ON
cmake --build build- Run the test suite:
./build/rtxui_test(orctest --test-dir build) - Run an example:
./build/rtxui_example_counter - Sanitizer build: add
-DRTXUI_SANITIZE=ONfor AddressSanitizer and UndefinedBehaviorSanitizer.
The examples under example/ are the fastest way to explore what the engine can do; each one is a single self-contained file.

