Set Up Development Environment#
A C++ compiler that supports C++20 (e.g., MSVC 2019 16.6 on Windows)
cmake (3.21 or newer)
Slint comes with a CMake integration that automates the compilation step of the
.slintmarkup language files and offers a CMake target for convenient linkage.
Note: We recommend using the Ninja generator of CMake for the most efficient build and
.slintdependency tracking. Install Ninja and select the CMake Ninja backend by passing
-GNinjaor set the
CMAKE_GENERATORenvironment variable to
Note: Binary packages are available for only Linux and Windows on x86-64 architecture. The recommended and most flexible way to use the C++ API is to build Slint from sources.
Install Binary Packages#
The Slint binary packages work without any Rust development environment.
Click on the latest release
From “Assets” (“XXX” refers to the version of the latest release),
for Linux x86-64 architecture - download
for Windows x86-64 architecture - download
Unpack the downloaded archive (Linux) or run the installer executable (Windows).
Set environment variables
CMAKE_PREFIX_PATHto the installation directory of Slint. Alternatively you can pass
-DCMAKE_PREFIX_PATH=/path/to/installed/slintargument when invoking cmake. This helps
find_package(Slint)to find Slint from within a
libsub-directory in the installation directory of Slint to
LD_LIBRARY_PATH(Linux) or to the
PATHenvironment variable (Windows). This is necessary to find the Slint libraries when running a Slint program.
In the next section you will learn how to use the installed library in your application and how to work with
.slint UI files.
Build From Sources#
First you need to install the prerequisites:
Install Rust by following the Rust Getting Started Guide. If you already have Rust installed, make sure that it’s at least version 1.60 or newer. You can check which version you have installed by running
rustc --version. Once this is done, you should have the
rustccompiler and the
cargobuild system installed in your path.
You can either choose to compile Slint from source along with your application or include Slint as an external CMake package.
To compile Slint along with your application, include Slint into your CMake project using CMake’s
FetchContentfeature. Insert the following snippet into your
CMakeLists.txtto make CMake download the latest released 1.x version, compile it, and make the CMake integration available:
# `release/1` will auto-upgrade to the latest Slint >= 1.0.0 and < 2.0.0
# `release/1.0` will auto-upgrade to the latest Slint >= 1.0.0 and < 1.1.0
To include Slint as an external CMake package, build Slint from source like a regular CMake project, install it into a prefix directory of your choice and use
The Slint library supports a set of features, not all of them enabled by default.
You might want to adapt the set of enabled features to optimize your binary
size. For example you might want to support only the wayland stack on Linux.
backend-winit-wayland feature while turning off the
backend-winit-x11 feature to do so.
Slint’s CMake configuration uses CMake options prefixed with
expose Slint’s feature flags at compile time. To have a wayland-only stack with
the CMake setup you would for example use:
cmake -DSLINT_FEATURE_BACKEND_WINIT=OFF -DSLINT_FEATURE_BACKEND_WINIT_WAYLAND=ON ...
Alternatively, you can use
ccmake for a more interactive way
to discover and toggle features.
This works when compiling Slint as a package, using
cmake --build and
cmake --install, or when including Slint using
Furthermore, you can set the
SLINT_LIBRARY_CARGO_FLAGS cache variable to specify additional flags for the Slint runtime during the build.
In Slint, a backend is the module that encapsulates the interaction with the operating system, in particular the windowing sub-system. Multiple backends can be compiled into Slint and one backend is selected for use at run-time on application start-up. You can configure Slint without any built-in backends, and instead develop your own backend by implementing Slint’s platform abstraction and window adapter interfaces.
For more information about the available backends, their system requirements, and configuration options, see the Backend & Renderers Documentation.
By default Slint will include both the Qt and
winit back-ends – if both are detected at
compile time. You can enable or disable back-ends using the
SLINT_FEATURE_BACKEND_ features. For example, to exclude the winit back-end,
you would disable the
SLINT_FEATURE_BACKEND_WINIT option in your CMake
The winit back-end needs a renderer.
SLINT_FEATURE_RENDERER_SKIA are the only stable renderers, the other ones are
It’s possible to cross-compile Slint to a different target architecture when building with CMake. You need to make sure your CMake setup is ready for cross-compilation, as documented in the upstream CMake documentation.
If you are building against a Yocto SDK, it is sufficient to source the SDK’s environment setup file.
Since Slint is implemented using the Rust programming language, you need to determine which Rust target matches the target architecture that you’re compiling for. Please consult the upstream Rust documentation to find the correct target name. Now you need to install the Rust toolchain:
rustup target add <target-name>
Then you’re ready to iconfigure your CMake project you need to add
-DRust_CARGO_TARGET=<target name> to the CMake command line.
This ensures that the Slint library is built for the correct architecture.
For example if you are building against an embedded Linux Yocto SDK targeting an ARM64 board, the following commands show how to compile:
Install the Rust targe toolchain once:
rustup target add aarch64-unknown-linux-gnu
Set up the environment and build:
cmake -DRust_CARGO_TARGET=aarch64-unknown-linux-gnu -DCMAKE_INSTALL_PREFIX=/slint/install/path ..
cmake --build .
cmake --install .
To target a Microcontroller environment, all of the following additional CMake configuration options must be set when compiling Slint:
|Enables building for environments without a standard library.
|Disables shared library support and instead builds Slint statically.
|Enable support for the software renderer.
|Default to pre-compiling images and fonts.
For example, if you’re targeting an MCU with a ARM Cortex-M processor, the complete command line for CMake could look like this:
cmake -DRust_CARGO_TARGET=thumbv7em-none-eabihf -DSLINT_FEATURE_FREESTANDING=ON