Skip to main content

Introduction

FLTK officially supports Windows 10 and later. The library can be built using:
  • Microsoft Visual Studio (2019 or later recommended)
  • MinGW/MSYS2 (GNU toolchain for native Windows)
  • Cygwin (POSIX compatibility layer - not actively tested)
Libraries built with different toolchains cannot be mixed. Choose one environment and use it consistently.

Visual Studio Build

Prerequisites

Install the required tools:
  1. Visual Studio - Download from visualstudio.microsoft.com
    • Visual Studio 2019 Community or later (free)
    • Visual Studio 2017 or later with CMake support
    • Earlier versions: Visual Studio 2008 with service packs (minimum)
  2. CMake - Download from cmake.org
    • Visual Studio 2017+ has built-in CMake support
    • Standalone CMake GUI recommended for older versions
Visual Studio Community Edition is free and fully functional for FLTK development.

Downloading FLTK

Download from fltk.org/software.phpExtract the archive to a convenient location, such as:
C:\Users\YourName\dev\fltk-1.x.y

Configuring with CMake

  1. Launch CMake GUI
  2. Set Where is the source code to your FLTK directory
  3. Set Where to build the binaries to C:\path\to\fltk\build
  4. Click Configure
  5. Select your Visual Studio version as the generator
  6. Choose platform (Win32 or x64)
  7. Click Done
  8. Review options and click Generate
  9. Click Open Project to launch Visual Studio
See README.CMake.txt for detailed configuration options.

Building FLTK

  1. Open FLTK.sln in Visual Studio
  2. Choose Debug or Release configuration
  3. Right-click the demo project
  4. Select Set as StartUp Project
  5. Press F7 or select Build > Build Solution

Testing FLTK

Run the demo program:
  1. Ensure demo is the StartUp project
  2. Press F5 or select Debug > Start Debugging
  3. Use the Demo launcher to explore test programs

Building Your Applications

Create a new Visual Studio project:
  1. Create a new Empty Project
  2. Add your source files (e.g., main.cxx)
  3. Configure project properties:
    • C/C++ > General > Additional Include Directories: C:\path\to\fltk\build
    • Linker > Input > Additional Dependencies: Add fltk.lib and Comctl32.lib
  4. Build and run with F5
Static linking (.lib files) is strongly recommended over DLLs to avoid version conflicts and deployment issues.

MinGW/MSYS2 Build

Prerequisites

Download and install MSYS2 from msys2.org.
As of December 2024, traditional MinGW development appears dormant. MSYS2 with MinGW-w64 is the recommended alternative.
Install required packages:
pacman -S base-devel
pacman -S mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-cmake
pacman -S git

Downloading FLTK

In the MSYS2 shell:
cd
mkdir dev
cd dev
git clone https://github.com/fltk/fltk.git
cd fltk
Or extract a source tarball:
tar xvzf fltk-1.x.y-source.tar.gz
cd fltk-1.x.y

Building FLTK

Configure and build:
cmake -B build -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release
cmake --build build

Testing FLTK

build/bin/test/demo.exe

Installing FLTK

System-wide installation:
cmake --install build
User-space installation:
cmake -B build -D CMAKE_INSTALL_PREFIX=$HOME/fltk
cmake --build build
cmake --install build

Building Your Applications

Use fltk-config to compile:
fltk-config --compile myProgram.cxx
Manual compilation:
g++ myProgram.cxx `fltk-config --cxxflags` `fltk-config --ldflags`

Windows-Specific Features

Console vs GUI Applications

Control whether your application shows a console window:
Use linker flags:
# GUI application (no console)
g++ -mwindows myapp.cxx `fltk-config --ldflags`

# Console application
g++ -mconsole myapp.cxx `fltk-config --ldflags`
Windows GUI applications cannot write to stdout, even when launched from a console.

FLUID Integration

Integrate FLUID (FLTK’s UI designer) into Visual Studio:
  1. Add a .fl file to your project as a header
  2. Right-click > Open With > Add fluid.exe
  3. Set as default editor
  4. Configure Custom Build Tool:
    • Command Line: fluid.exe -c $(InputPath)
    • Description: Compiling Fluid .fl file
    • Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
  5. Add the generated .cxx file to your project

OpenGL Support

OpenGL should work automatically. To verify OpenGL is enabled, check config.h:
#define HAVE_GL 1
Link against OpenGL libraries in your project settings.

Troubleshooting

Line Ending Issues

If you encounter compilation errors with Git-obtained sources:
error: 'U32' does not name a type
Convert files to Unix line endings (LF):
unix2dos configh.in
Modern Git should handle this automatically.

Missing —enable-auto-import

Older MinGW/MSYS versions may need:
cmake -B build -D CMAKE_EXE_LINKER_FLAGS="-Wl,--enable-auto-import"
Upgrade to a current release to avoid this issue.

CMake Generator Issues

Ensure you’re using the correct generator:
cmake --help
Lists available generators for your platform.

Additional Resources

Build docs developers (and LLMs) love