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:
Debian/Ubuntu
Fedora
NetBSD
Solaris/OpenIndiana
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
Optional but Recommended Packages
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
Install the required development packages:su root
yum groupinstall "Development Tools"
yum groupinstall "X Software Development"
yum groupinstall "C Development Tools and Libraries"
Exit root status (Ctrl-D) before building FLTK. Ensure the optional distribution sets are installed:
- comp: Compiler, header files, development tools
- x*: X Window System
Install and configure pkgsrc from pkgsrc.org.For the latest development version:cd /usr/pkgsrc/devel/git
bmake install
git clone https://github.com/fltk/fltk.git
If using JPEG/PNG libraries from pkgsrc:export CPPFLAGS="-I/usr/pkg/include"
export LDFLAGS="-L/usr/pkg/lib"
FLTK requires at least SunOS 5.7 (Solaris 7) with POSIX threads support.For Sun compilers with pkgsrc libraries:export CC="cc"
export CXX="CC"
export CPPFLAGS="-I/usr/pkg/include"
export LDFLAGS="-L/usr/pkg/lib -R/usr/pkg/lib"
For 64-bit builds:export CFLAGS="-xarch=v9"
export CXXFLAGS="-xarch=v9"
Downloading FLTK
Download the latest stable release or development version:
Stable Release
Git Development
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
Clone the latest development version:git clone https://github.com/fltk/fltk.git
cd fltk
Update to the latest version:
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:
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:
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:
- Select File > New > Project
- Choose FLTK project template
- Follow the wizard
To add FLUID support:
- Go to Settings > Compiler and debugging settings > Other settings > Advanced options
- Add extension:
fl
- Command line macro:
cd $file_dir; fluid -c $file
- Generated files:
$file_dir/$file_name.cxx and $file_dir/$file_name.h
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:
Debian/Ubuntu
Fedora
NetBSD
sudo apt-get install libfltk1.3-dev
sudo yum install fltk-devel
cd /usr/pkgsrc/x11/fltk13
bmake install
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