In short, I found a possible bug or I messed up my project configuration.
Here is the diff for what I thing is a bug.
Fl_Cairo.h`
-# include <cairo.h>
+# include <cairo/cairo.h>
Can anybody confirm that I messed up or is this a real problem?
For a project I need to use FLTK once on MSVC and once on Debian. I have a MSVC background and the last time of serious work with *nix is more than 25 years ago. So, I'm a bit rusty on that side.
I created a virual machine with Debian 13 (trixie) and configured a development environment. One of the things I installed was `sudo apt install libfltk1.4-dev` together with all its dependencies.
Then I created a simple test program with the following details.
CMakeLists.txt
# bare bone cmake file for test of FLTK with one main.cpp source file.
cmake_minimum_required(VERSION 3.31.6)
project( TestLibFltk LANGUAGES CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(FLTK REQUIRED)
add_executable(TestLibFltk main.cpp)
target_compile_features(TestLibFltk INTERFACE cxx_std_17)
target_include_directories(TestLibFltk PUBLIC ${FLTK_INCLUDE_DIR})
#target_include_directories(TestLibFltk PUBLIC /usr/include/cairo )
andre@debian:~/development/FLTK/LibTest/sources$ cmake --build ../build
[ 50%] Building CXX object CMakeFiles/TestLibFltk.dir/main.cpp.o
In file included from /usr/include/FL/Fl.H:30,
from /home/andre/development/FLTK/LibTest/sources/main.cpp:2:
/usr/include/FL/Fl_Cairo.H:40:11: fatal error: cairo.h: No such file or directory
40 | # include <cairo.h>
| ^~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/TestLibFltk.dir/build.make:79: CMakeFiles/TestLibFltk.dir/main.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/TestLibFltk.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
andre@debian:~/development/FLTK/LibTest/sources$
Some checking showed that `cairo.h` is lokated in in `usr/include/cairo`.
And Fl_Cairo.h r40 `# include <cairo.h>` does not work.
I may have made de mistake in not adding all paths for include files but the way it is organised
makes me thing that there is a mistake in Fl_Cairo.h
Changing r40 to `# include <cairo/cairo.h>` should fix it.
But is not what I did, I do not like to change installed packages.
I added an extra include line in CMakeLists.txt (the one in comments in the listing above).
Now it compiles, links and I can start the result without a problem.
I agree that there is more than just one path and that CMake should check for the dependencies.The hard coded path was just a quick workaround. With some test code like this it shows something but it is not how it should be done.
But I see a problem here. For me FLTK-1.4.3 is the only known dependency for this code.What other (implicit) dependencies are there? Where do I get information on what to check?
Did I miss something in the documentation?
> Did you read README.CMake.txt ?
Yep, the 1.4.4 version of it, and did reread it just now.
As well as README.Cairo.txt
Some of the prolems look related to finding the cairo package. This are the install details. [...]
> find_package(FLTK 1.4 CONFIG REQUIRED)
I am aware of that but can't get it to work.
cmake_minimum_required(VERSION 3.31.6)
project( TestLibFltk LANGUAGES CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(FLTK 1.4 REQUIRED)
add_executable(TestLibFltk main.cpp)
target_compile_features(TestLibFltk INTERFACE cxx_std_17) # optional but I stick to it.
target_link_libraries(TestLibFltk PRIVATE fltk::fltk})
andre@debian:~/development/FLTK/LibTest/sources$ cmake -S . -B ../build
CMake Error at /usr/share/fltk/FLTK-Targets-none.cmake:192 (add_library):
add_library cannot create imported target "fltk::fluid" because another
target with the same name already exists.
...
CMake Error at /usr/share/fltk/FLTK-Targets-none.cmake:222 (add_library):
add_library cannot create imported target "fltk::options" because another
target with the same name already exists.
...
CMake Error at /usr/share/fltk/FLTK-Targets.cmake:181 (message):
The imported target "fltk::fluid-shared" references the file
"/usr/bin/fluid-shared"
...
-- Configuring incomplete, errors occurred!
I do not know what to do with this result.
Then I tried to detect Cairo in the top CMakeLists.txt file, this also fails.
cmake_minimum_required(VERSION 3.31.6)
project( TestLibFltk LANGUAGES CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Cairo REQUIRED)
find_package(FLTK 1.4 REQUIRED)
add_executable(TestLibFltk main.cpp)
target_compile_features(TestLibFltk INTERFACE cxx_std_17)
target_include_directories(TestLibFltk PUBLIC ${FLTK_INCLUDE_DIR})
target_link_libraries(TestLibFltk PRIVATE ${FLTK_LIBRARIES})
target_link_libraries(TestLibFltk PRIVATE cairo::cairo})
andre@debian:~/development/FLTK/LibTest/sources$ cmake -S . -B ../build
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "FindCairo.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Cairo", but
CMake did not find one.
Could not find a package configuration file provided by "Cairo" with any of
the following names:
CairoConfig.cmake
cairo-config.cmake
> Sigh. :-(
Look at the bright side, you are in known territory now. ;-)
fltk-options/stable,now 1.4.3-1 amd64 [installed] (2) fltk1.4-games/stable,now 1.4.3-1 amd64 [installed] (2) fluid/stable,now 1.4.3-1 amd64 [installed] (2) libfltk1.4-dev/stable,now 1.4.3-1 amd64 [installed] (1)Notes:
cmake_minimum_required(VERSION 3.15)
project(fltk-versions)
find_package(FLTK 1.4 CONFIG REQUIRED)
set(prog fltk-versions)
add_executable( ${prog} WIN32 MACOSX_BUNDLE ${prog}.cxx)
target_include_directories( ${prog} PRIVATE ${FLTK_INCLUDE_DIRS})
target_link_libraries( ${prog} PRIVATE ${FLTK_LIBRARIES})
Notes:
- text in red color is old-style but unfortunately required in
Debian Trixiecmake_minimum_required(VERSION 3.15)
project(fltk-versions)
find_package(FLTK 1.4 CONFIG REQUIRED)
set(prog fltk-versions)
add_executable( ${prog} WIN32 MACOSX_BUNDLE ${prog}.cxx)
target_link_libraries( ${prog} PRIVATE fltk::fltk)
... and should work as well.Good news: although the installed packages are broken (from an FLTK developer's view) I could find a way to install required packages and build two simple FLTK apps: one with libfltk_images (implies libfltk) and one like a simple hello-world application that uses only libfltk.
(A) Install at least these four packages (output from `apt list --installed`):
fltk-options/stable,now 1.4.3-1 amd64 [installed] (2) fltk1.4-games/stable,now 1.4.3-1 amd64 [installed] (2) fluid/stable,now 1.4.3-1 amd64 [installed] (2) libfltk1.4-dev/stable,now 1.4.3-1 amd64 [installed] (1)
(B) Write your CMakeLists.txt like this:
cmake_minimum_required(VERSION 3.15) project(fltk-versions) find_package(FLTK 1.4 CONFIG REQUIRED) set(prog fltk-versions) add_executable( ${prog} WIN32 MACOSX_BUNDLE ${prog}.cxx) target_include_directories( ${prog} PRIVATE ${FLTK_INCLUDE_DIRS}) target_link_libraries( ${prog} PRIVATE ${FLTK_LIBRARIES})
Unfortunately these "tricks" are required in Debian Trixie. This is not what we (the FLTK Team) wanted and how "modern CMake" is intended to work.
Note: if you built FLTK 1.4 yourself your CMakeList.txt should look like this "modern CMake" version:
Please test, and ideally confirm that this works for you so we can add this to our docs.
Op zaterdag 10 januari 2026 om 19:54:39 UTC+1 schreef Albrecht-S:
Good news: although the installed packages are broken (from an FLTK developer's view) I could find a way to install required packages and build two simple FLTK apps: one with libfltk_images (implies libfltk) and one like a simple hello-world application that uses only libfltk....
Before I start building v1.4.4 I try this work around for documentation purposes.
Unfortunately, it fails. ...
Note: if you built FLTK 1.4 yourself your CMakeList.txt should look like this "modern CMake" version:
cmake_minimum_required(VERSION 3.15) project(fltk-versions) find_package(FLTK 1.4 CONFIG REQUIRED) set(prog fltk-versions) add_executable( ${prog} WIN32 MACOSX_BUNDLE ${prog}.cxx) target_link_libraries( ${prog} PRIVATE fltk::fltk) ... and should work as well.
Please test, and ideally confirm that this works for you so we can add this to our docs.
and now for part two (have success this time.)
Op zaterdag 10 januari 2026 om 19:54:39 UTC+1 schreef Albrecht-S:
Note: if you built FLTK 1.4 yourself your CMakeList.txt should look like this "modern CMake" version:
cmake_minimum_required(VERSION 3.15) project(fltk-versions) find_package(FLTK 1.4 CONFIG REQUIRED) set(prog fltk-versions) add_executable( ${prog} WIN32 MACOSX_BUNDLE ${prog}.cxx) target_link_libraries( ${prog} PRIVATE fltk::fltk) ... and should work as well.
build of v1.4.4
andre@debian:~/development/FLTK/LibBuild-1.4/fltk-branch-1.4$ cmake -S . -B ../build --fresh
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- ...
-- Found JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (found version "62")
-- Checking for module 'wayland-client>=1.18'
-- Package 'wayland-client', required by 'virtual:world', not found
-- Checking for module 'wayland-cursor'
-- Package 'wayland-cursor', required by 'virtual:world', not found
-- Checking for module 'wayland-protocols>=1.15'
-- Package 'wayland-protocols', required by 'virtual:world', not found
-- Checking for module 'xkbcommon'
-- Package 'xkbcommon', required by 'virtual:world', not found
-- Not all software modules 'wayland-client>=1.18 wayland-cursor wayland-protocols>=1.15 xkbcommon' are present
-- Consequently, FLTK_BACKEND_WAYLAND is turned off.
...-- Found X11: /usr/include
-- Configuration Summary for FLTK 1.4.4 generated by CMake 3.31.6 --
-- The following OPTIONAL packages have been found:
* ZLIB
* PNG
* JPEG
-- The following OPTIONAL packages have not been found:
* Doxygen
-- Static libraries will be built in: /home/andre/development/FLTK/LibBuild-1.4/build/lib
-- Shared libraries will not be built (set FLTK_BUILD_SHARED_LIBS=ON to build)
-- The forms library will be built in: /home/andre/development/FLTK/LibBuild-1.4/build/lib
-- The OpenGL library will be built in: /home/andre/development/FLTK/LibBuild-1.4/build/lib
-- fluid will be built in: /home/andre/development/FLTK/LibBuild-1.4/build/bin
-- fltk-options will be built in: /home/andre/development/FLTK/LibBuild-1.4/build/bin
-- Test programs will be built in: /home/andre/development/FLTK/LibBuild-1.4/build/bin/test
-- Example programs will not be built (set FLTK_BUILD_EXAMPLES=ON to build)
--
-- Build configuration <unspecified>
-- Installation prefix /usr/local
-- Bundled Libraries JPEG = System: /usr/lib/x86_64-linux-gnu/libjpeg.so
-- PNG = System: /usr/lib/x86_64-linux-gnu/libpng.so
-- ZLIB = System: /usr/lib/x86_64-linux-gnu/libz.so
-- Use Wayland No (X11 is used)
-- All drawing uses Cairo No
-- Use Pango No
compile it...andre@debian:~/development/FLTK/LibBuild-1.4/fltk-branch-1.4$ cmake --build ../build
...
[100%] Linking CXX executable ../bin/test/shape
[100%] Built target shape
[100%] Building CXX object test/CMakeFiles/shadow_variables.dir/shadow_variables.cxx.o
[100%] Linking CXX executable ../bin/test/shadow_variables
[100%] Built target shadow_variables
And none of the problems reported.
Tried a number of the test programs, sudoku works fine, somehow doublebuffer is very pleasing to my eyes.
Back to the test program. I deviated from the proposed CMakeLists.txt file by adding FLTK_DIR in the file,. (Should have done this as a command line argument.)
fltk-versions runs fine but does not do very much.
It seems I have something going this time.
Please test, and ideally confirm that this works for you so we can add this to our docs.
Done with pleasure.
On 1/10/26 21:58 Andre Steenveld wrote:
and now for part two (have success this time.)
Great, thanks!
But ... there's always a (tiny) "but", isn't it? No need to worry, but see below..
build of v1.4.4andre@debian:~/development/FLTK/LibBuild-1.4/fltk-branch-1.4$ cmake -S . -B ../build --fresh
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0-- ...
All good so far, and here comes the "but", part 1:
-- Found JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (found version "62")
-- Checking for module 'wayland-client>=1.18'
-- Package 'wayland-client', required by 'virtual:world', not found
-- Checking for module 'wayland-cursor'
-- Package 'wayland-cursor', required by 'virtual:world', not found
-- Checking for module 'wayland-protocols>=1.15'
-- Package 'wayland-protocols', required by 'virtual:world', not found
-- Checking for module 'xkbcommon'
-- Package 'xkbcommon', required by 'virtual:world', not found
-- Not all software modules 'wayland-client>=1.18 wayland-cursor wayland-protocols>=1.15 xkbcommon' are present
-- Consequently, FLTK_BACKEND_WAYLAND is turned off.
There are some Wayland -dev packages missing, hence Wayland is disabled (see README.Wayland for how to fix this if you like).
-- Use Wayland No (X11 is used)
-- All drawing uses Cairo No
-- Use Pango No
Since Wayland is disabled, Cairo drawing is disabled as well, and your build uses standard X11 graphics.
That's not bad per se, but it's not "the same" as the Debian (hybrid) FLTK library would provide.
Good so far.Back to the test program. I deviated from the proposed CMakeLists.txt file by adding FLTK_DIR in the file,. (Should have done this as a command line argument.)
Good, and yes, setting a CMake variable (in the cache) is the recommended way.
If you still like to test my patch, that'd be appreciated.
Op zaterdag 10 januari 2026 om 22:17:20 UTC+1 schreef Albrecht-S:
There are some Wayland -dev packages missing, hence Wayland is disabled (see README.Wayland for how to fix this if you like).
What sould I install to tackle this?
These packages are necessary to build the FLTK library, in addition to those listed in section 2.1 of file README.Unix.txt : sudo apt-get install libpango1.0-dev sudo apt-get install libwayland-dev sudo apt-get install wayland-protocols sudo apt-get install libxkbcommon-dev sudo apt-get install libxinerama-dev # except if option FLTK_BACKEND_X11=off is used sudo apt-get install libdbus-1-dev # recommended to query current cursor theme sudo apt-get install libglew-dev # necessary to use OpenGL version 3 or above sudo apt-get install libdecor-0-dev # recommended if available and if in version ≥ 0.2.0 sudo apt-get install libgtk-3-dev # highly recommended if libdecor-0-dev is not installed These packages allow to run FLTK apps under the Gnome-Wayland desktop: sudo apt-get install gnome-core sudo apt-get install libdecor-0-plugin-1-gtk # install if libdecor-0-dev is installed These packages allow to run FLTK apps under the KDE/Plasma-Wayland desktop: sudo apt-get install kde-plasma-desktop```
On 1/10/26 21:16 Andre Steenveld wrote:
To apply my patch you need to replace (as root!) the file /usr/share/fltk/FLTK-Targets-none.cmake with the one I attach to this mail. Please backup the original file before you replace it.
I hope this helps, finally.
To verify that this was the real cause I reinstalled the original libfltk1.4-dev package, found the same issues you reported, and applied my patch which resolved the issue again.
Note: this happened because I lost track of the patch(es) I had done on my Debian Trixie VM. I apologize for the extra work you need to do now.
Note also that the patch is only a minimal version to resolve the issue, not a complete solution. In a later Debian version this file should hopefully be fixed (overwritten by upgrading the package).
Hint: if you like to test and learn more: there are a lot of test and
demo programs included in the FLTK distribution in /test/ and /examples/
folders.
> Note that FLTK-v1.4.3 is still installed but not used.
OK, but this can constitute a problem.
> If anyting else is needed I'm willing to test a bit more.
Yes, if you like: as I wrote before, I'd appreciate if you could also
test my patch I posted recently. But note that you need to change a
system file with root access. TIA
Op zaterdag 10 januari 2026 om 21:57:07 UTC+1 schreef Albrecht-S:
On 1/10/26 21:16 Andre Steenveld wrote:
...To apply my patch you need to replace (as root!) the file /usr/share/fltk/FLTK-Targets-none.cmake with the one I attach to this mail. Please backup the original file before you replace it.
I hope this helps, finally.
To verify that this was the real cause I reinstalled the original libfltk1.4-dev package, found the same issues you reported, and applied my patch which resolved the issue again.
It does not work on my installation. Here is what I did.
First I updated all packages according to the README files.Then I did a rebuild on v1.4.4 to check what the build would be.
andre@debian:~/development/FLTK/LibBuild-1.4/fltk-branch-1.4$ cmake -S . -B ../build --fresh
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Use Wayland Yes (can also run as X11 client)
-- All drawing uses Cairo Yes
-- Use Pango Yes
Before I updated the cmake script I checked once more if generating a build with v1.4.3 is working or not.As expected that did not work.
After that I updated the scrip by moving the original one out of the way and copying the new one and checking permissions.
andre@debian:/usr/share/fltk$ ls -la
total 84
drwxr-xr-x 2 root root 4096 Jan 11 11:18 .
drwxr-xr-x 260 root root 12288 Jan 11 11:03 ..
-rw-r--r-- 1 root root 255 Apr 30 2025 CMakeCache.txt
-rw-r--r-- 1 root root 5009 Apr 30 2025 FLTKConfig.cmake
-rw-r--r-- 1 root root 3214 Apr 30 2025 FLTKConfigVersion.cmake
-rw-r--r-- 1 root root 2931 Apr 29 2025 FLTK-Functions.cmake
-rw-r--r-- 1 root root 14671 Apr 30 2025 FLTK-Targets.cmake
-rw-r--r-- 1 root root 15013 Jan 11 11:18 FLTK-Targets-none.cmake
-rw-r--r-- 1 root root 14979 Apr 30 2025 FLTK-Targets-none.org.cmake
andre@debian:/usr/share/fltk$
Then another try, this time it failed with more comments.
andre@debian:~/development/FLTK/LibTest/sources$ cmake -S . -B ../build --fresh
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
...
CMake Error at /usr/share/fltk/FLTK-Targets-none.org.cmake:29 (add_library):
add_library cannot create imported target "fltk::cairo" because another
target with the same name already exists.
Call Stack (most recent call first):
/usr/share/fltk/FLTK-Targets.cmake:166 (include)
/usr/share/fltk/FLTKConfig.cmake:39 (include)
CMakeLists.txt:3 (find_package)
Note also that the patch is only a minimal version to resolve the issue, not a complete solution. In a later Debian version this file should hopefully be fixed (overwritten by upgrading the package).
Unfortunately, not working on my system.
I guess that's the cause of the following behavior because CMake includes files with a wildcard:
Then another try, this time it failed with more comments.
andre@debian:~/development/FLTK/LibTest/sources$ cmake -S . -B ../build --fresh
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0...
CMake Error at /usr/share/fltk/FLTK-Targets-none.org.cmake:29 (add_library):
add_library cannot create imported target "fltk::cairo" because another
target with the same name already exists.
Call Stack (most recent call first):
/usr/share/fltk/FLTK-Targets.cmake:166 (include)
/usr/share/fltk/FLTKConfig.cmake:39 (include)
CMakeLists.txt:3 (find_package)
As you can see the CMake script includes the old one as well.
Please remove it from this directory to be sure! (Maybe renaming it to 'something.txt' would work as well.)
...
Can you give it another try after *removing* the offending file "FLTK-Targets-none.org.cmake"(saving it elsewhere). Note also that you can always reinstall the FLTK package to restore the original file.
Thanks in advance.
Op zondag 11 januari 2026 om 15:34:27 UTC+1 schreef Albrecht-S:
On 1/11/26 11:35 Andre Steenveld wrote:
It does not work on my installation. Here is what I did.
...
After that I updated the scrip by moving the original one out of the way and copying the new one and checking permissions.
andre@debian:/usr/share/fltk$ ls -la
total 84
drwxr-xr-x 2 root root 4096 Jan 11 11:18 .
drwxr-xr-x 260 root root 12288 Jan 11 11:03 ..
-rw-r--r-- 1 root root 255 Apr 30 2025 CMakeCache.txt
-rw-r--r-- 1 root root 5009 Apr 30 2025 FLTKConfig.cmake
-rw-r--r-- 1 root root 3214 Apr 30 2025 FLTKConfigVersion.cmake
-rw-r--r-- 1 root root 2931 Apr 29 2025 FLTK-Functions.cmake
-rw-r--r-- 1 root root 14671 Apr 30 2025 FLTK-Targets.cmake
-rw-r--r-- 1 root root 15013 Jan 11 11:18 FLTK-Targets-none.cmake
-rw-r--r-- 1 root root 14979 Apr 30 2025 FLTK-Targets-none.org.cmake
andre@debian:/usr/share/fltk$
Does "moving the original one out of the way" mean that you renamed it to "FLTK-Targets-none.org.cmake" ? (I don't have this file on my system.)
yes.I guess that's the cause of the following behavior because CMake includes files with a wildcard:
I was not aware of that. And to be honest, I did not check the result thorouhly
...
I can do more testing if you want.But if you think all testing is done I would like to continue with removing all of FLTK-v1.4.3, install FLTK-v1.4.4 and see how that behaves.
This is somewhat orthogonal to the config/cmake issues that this thread is about, but the OP said the objective is to build "the same" program for both Windows & Linux.So I thought it might be handy to throw in a few pointers about that:
...
If you really want to "install" FLTK 1.4.4 (or maybe 1.4.5 soon, maybe in 2-3 weeks?) you should be aware of some things:
...
Feedback welcome.