Skip to main content

Introduction

FLTK supports most Unix and Linux platforms using CMake as the build system. This guide covers building FLTK on various Linux distributions and Unix systems including Debian, Ubuntu, Fedora, NetBSD, and more.
Since FLTK 1.5.0, autotools and configure-based builds are no longer supported. You must use CMake.

Prerequisites

Required Packages

FLTK requires certain development packages to be installed. Choose the section for your distribution:
Install the core development tools and X11 libraries:
sudo apt-get install g++
sudo apt-get install gdb
sudo apt-get install git
sudo apt-get install cmake
sudo apt-get install libx11-dev
sudo apt-get install libglu1-mesa-dev
sudo apt-get install libxft-dev
sudo apt-get install libxcursor-dev
sudo apt-get install libasound2-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libcairo2-dev
sudo apt-get install libfontconfig1-dev
sudo apt-get install libglew-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libpango1.0-dev
sudo apt-get install libxinerama-dev
For Wayland support, see the Wayland platform guide.

Downloading FLTK

Download the latest stable release or development version:
Download from fltk.org/software.php:
cd ~
mkdir dev
cd dev
tar xvzf ~/Downloads/fltk-1.x.y-source.tar.gz
cd fltk-1.x.y

Building FLTK

Quick Build

Build FLTK with default settings:
cmake . -B build -D CMAKE_BUILD_TYPE=Debug
cmake --build build
Replace Debug with Release for optimized production builds.

Configuration Options

View available configuration options:
cmake -L .
Common options:
  • -D CMAKE_BUILD_TYPE=Debug|Release - Build type
  • -D CMAKE_INSTALL_PREFIX=/path - Installation directory
  • -D FLTK_BUILD_SHARED_LIBS=ON - Build shared libraries
  • -D FLTK_BUILD_EXAMPLES=ON - Build example programs
For more details, see README.CMake.txt in the FLTK source directory.

Testing FLTK

Run the demo program to test the build:
cd build
test/demo
The demo launcher provides access to all FLTK test programs.

Installing FLTK

Install to the default location (/usr/local):
sudo cmake --install build
Install to a custom location without superuser privileges:
cmake . -B build -D CMAKE_INSTALL_PREFIX=$HOME/fltk
cmake --build build
cmake --install build
Installing FLTK system-wide is optional. You can build applications directly against the build tree, which is recommended for static linking and avoiding version conflicts.

Building Your Applications

Using fltk-config

FLTK provides the fltk-config script to simplify compilation:
fltk-config --compile myProgram.cxx
For multiple source files:
fltk-config --compile file1.cxx file2.cxx file3.cxx
Get compiler and linker flags:
fltk-config --cxxflags
fltk-config --ldflags

Using CMake

For larger projects, use CMake. Create a CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(MyApp)

find_package(FLTK REQUIRED)

add_executable(myapp main.cxx)
target_link_libraries(myapp FLTK::fltk)
Build your project:
cmake -B build
cmake --build build

IDE Integration

Code::Blocks

Install Code::Blocks IDE:
sudo apt-get install codeblocks
Create a new FLTK project:
  1. Select File > New > Project
  2. Choose FLTK project template
  3. Follow the wizard
To add FLUID support:
  1. Go to Settings > Compiler and debugging settings > Other settings > Advanced options
  2. Add extension: fl
  3. Command line macro: cd $file_dir; fluid -c $file
  4. Generated files: $file_dir/$file_name.cxx and $file_dir/$file_name.h

Platform Features

Display Backend

Linux FLTK supports both X11 and Wayland backends:
  • X11: Traditional X Window System (always available)
  • Wayland: Modern display protocol (see Wayland guide)
By default, FLTK builds with hybrid Wayland/X11 support and automatically selects the appropriate backend at runtime.

Font Rendering

FLTK uses:
  • Xft: Anti-aliased font rendering (X11)
  • Pango: Text rendering and international text support (Wayland)

Graphics

  • Cairo: Vector graphics library (optional)
  • OpenGL: Hardware-accelerated 3D graphics

Distribution Packages

Many distributions provide pre-built FLTK packages:
sudo apt-get install libfltk1.3-dev
Distribution packages may be outdated. Building from source is recommended for the latest features and bug fixes.

Troubleshooting

Missing Dependencies

If CMake reports missing dependencies, install the required development packages for your distribution.

Symbol Font Issues

The Symbol and Zapf Dingbats fonts do not work on X11 UTF-8 platforms. This is expected behavior.

Build Warnings

The ranlib tool may report modules with no symbols. This is normal and can be safely ignored.

Additional Resources

Build docs developers (and LLMs) love