This is an example project that shows how to run LVGL
on GNU/Linux and other Unix-like systems. It builds a small simulator
application, lvglsim, that opens a window (or drives a display directly) and
runs LVGL's demos. It can also be used as a starting point to cross-compile LVGL to
an embedded linux board.
LVGL ships drivers for the whole Linux graphics stack, and this port can build against any of them:
| Backend | Description |
|---|---|
LV_USE_SDL |
SDL2 (default) — a desktop window |
LV_USE_WAYLAND |
Wayland |
LV_USE_X11 |
X11 |
LV_USE_GLFW |
GLFW3 (OpenGL) |
LV_USE_LINUX_DRM |
DRM/KMS (/dev/dri/*) |
LV_USE_LINUX_FBDEV |
Legacy framebuffer (/dev/fb*) |
Configuration is driven by Kconfig, the same system used by the Linux kernel, so you can pick drivers, features and demos from a menu instead of editing a header by hand.
CMake, Python 3, and python3-venv are required regardless of configuration. Ninja is optional but recommended to speed-up building
Install all system dependencies in one go:
# Debian / Ubuntu
sudo apt install \
build-essential cmake python3 python3-venv ninja-build \
libsdl2-dev \
libwayland-dev libxkbcommon-dev wayland-protocols \
libx11-dev \
libdrm-dev libgbm-dev \
libevdev-dev \
libwebp-dev \
libegl-dev libgles-dev libgl-dev# Arch
sudo pacman -S \
git cmake python ninja \
sdl2 \
wayland wayland-protocols libxkbcommon \
libx11 \
libdrm \
libevdev \
libwebp \
mesa# Fedora
sudo dnf install \
@development-tools gcc-c++ cmake python3 python3-devel ninja-build \
SDL2-devel \
wayland-devel wayland-protocols-devel libxkbcommon-devel \
libX11-devel \
libdrm-devel \
libevdev-devel \
libwebp-devel \
mesa-libEGL-devel mesa-libGLES-devel mesa-libGL-devel mesa-libgbm-develLibraries that can be fetched from source (FreeType, libpng, libjpeg-turbo, ...) are built automatically by CMake if not found on the system.
FFmpeg and GStreamer must be installed manually if you enable them:
# Debian / Ubuntu
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
# Arch
sudo pacman -S ffmpeg gstreamer gst-plugins-base
# Fedora
sudo dnf install ffmpeg-devel gstreamer1-devel gstreamer1-plugins-base-develInstall the system packages with your distribution's package manager, then install the Python tools in a virtual environment (recommended so they don't pollute your system Python):
python3 -m venv env
source env/bin/activate
pip install kconfiglib pcppLVGL is included as a git submodule, so clone recursively:
git clone --recurse-submodules https://github.com/lvgl/lv_port_linux.git
cd lv_port_linuxcmake -B build -GNinja
cmake --build build
./build/bin/lvglsimConfiguration lives in a .config file at the repository root. When it exists,
the build uses it; otherwise it falls back to configs/get_started.defconfig.
The Kconfig tools (defconfig, menuconfig) come from kconfiglib and must be
run from the repository root, where the top-level Kconfig lives.
Generate a .config from a defconfig:
defconfig configs/get_started.defconfigBesides the port's own get_started.defconfig, LVGL ships several ready-made
defconfigs in lvgl/configs/defconfigs/.
Apply one the same way, e.g.:
defconfig lvgl/configs/defconfigs/wayland.defconfigOnce you have a .config, open the interactive menu to enable/disable drivers,
features, fonts and demos:
menuconfigSave and exit, then rebuild:
cmake -B build
cmake --build build -j$(nproc)This port supports these Linux display and input backend that LVGL provides.
A backend is compiled in when its CONFIG_LV_USE_* option is enabled (through
Kconfig, as above). The glue code for each one lives in:
- Displays:
src/lib/display_backends—sdl,wayland,x11,glfw3,drm,fbdev - Input devices:
src/lib/indev_backends—evdev
If several backends are enabled at once, pick one at runtime with -b:
./build/bin/lvglsim -b sdlList the backends compiled into your binary with -B. Run ./build/bin/lvglsim -h
for all options (fullscreen, window size, rotation, …).
LVGL can load and render 3D scenes (such as .gltf and .glb files)
when using hardware-accelerated backends:
defconfig configs/get_started_3d.defconfig
cmake -B build -GNinja
cmake --build build
./build/bin/lvglsimCross compilation is supported with CMake. Edit
cmake/user_cross_compile_setup.cmake to point at your toolchain, then:
cmake -B build -GNinja -DCMAKE_TOOLCHAIN_FILE=./user_cross_compile_setup.cmake
cmake --build buildYou can install the built LVGL library and headers to your system:
cmake --install ./buildThe boards/ directory contains hardware-specific documentation and
configuration files for running LVGL on officially supported embedded Linux development
boards. Currently supported boards:
- F&S PicoCoreMX93: NXP i.MX93-based system-on-module
- GLYN UI2 Starter Kit: GLYN starter kit with the Renesas RZ/G2L
- NXP i.MX93: NXP's i.MX93 evaluation platform
- Renesas RZ/G3E EVKit: Renesas RZ/G3E evaluation kit
- Texas Instruments SK-AM62B-P1: AM62B starter kit
- Texas Instruments SK-AM62L: AM62L starter kit
- Texas Instruments SK-AM62P-LP: AM62P low-power starter kit
- Toradex Verdin AM62: Toradex Verdin module with TI AM62 processor
- Toradex Verdin iMX8M Mini: Toradex Verdin module with NXP i.MX8M Mini processor
- STM32MP157F-DK2: STMicroelectronics MP1 processor devkit with touchscreen
Environment variables can be set to modify the behavior of the simulator. Check the driver documentation for more details.
Simply export them on your current shell instance before launching the compiled application to see them take effect:
export LV_LINUX_FBDEV_DEVICE="/dev/fb1"
./build/bin/lvglsimLV_SIM_WINDOW_WIDTH— width of the window (default800).LV_SIM_WINDOW_HEIGHT— height of the window (default480).
LV_LINUX_FBDEV_DEVICE— override the default (/dev/fb0) framebuffer device node.
LV_LINUX_EVDEV_POINTER_DEVICE— the path of the input device, e.g./dev/input/by-id/my-mouse-or-touchscreen. If not set, devices are discovered and added automatically.
LV_LINUX_DRM_CARD— override the default (/dev/dri/card0) card.
Some devices require special permissions. We recommend adding your user to the appropriate group to avoid running the application with sudo.
Access requirements depend on which drivers you choose to use:
videogroup: Grants access to the framebuffer (/dev/fb0) if usingfbdev.inputgroup: Grants access to event devices (/dev/input/*) if usingevdev.
If you are using either driver, add your user to the corresponding group(s):
# Add your user to the relevant group(s)
sudo adduser $USER video
sudo adduser $USER input
# Apply group changes to the current terminal session
newgrp video
./build/bin/lvglsimNote: If your display/input setup does not rely on fbdev or evdev (for example, if you are using SDL, X11, or Wayland), you can safely skip these group permission steps.