On Windows there's only a single check done:
/* We require Windows 8 or later features for Pen/Tablet support */
# if !defined(WINVER) || (WINVER < 0x0602)
# ifdef WINVER
# undef WINVER
# endif
# define WINVER 0x0602
# endif
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0602)
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# endif
# define _WIN32_WINNT 0x0602
# endif
#include <windows.h>
int main() {
return POINTER_CHANGE_FIRSTBUTTON_DOWN; /* required symbol */
}
>
> Anyway, I don't think we can realistically fill in all the missing
> pieces, so I guess that toolchain is a lost cause!
You can disable pen support entirely by using CMake option
"FLTK_OPTION_PEN_SUPPORT - default ON". This *should* disable
compilation of all pen support code. If this doesn't help, then this is
supposedly a bug in our source code.
On Thursday, 18 June 2026 at 08:02:56 UTC+1 Albrecht wrote:
[Ian wrote]
> Anyway, I don't think we can realistically fill in all the missing
> pieces, so I guess that toolchain is a lost cause!
You can disable pen support entirely by using CMake option
"FLTK_OPTION_PEN_SUPPORT - default ON". This *should* disable
compilation of all pen support code. If this doesn't help, then this is
supposedly a bug in our source code.
There's no problem with the FLTK build as such (other than pen support not working.)It actually builds fine with FLTK_OPTION_PEN_SUPPORT either set or unset - so there's no "bug" as such (other than with the migw32 headers being Too Old, which is not our fault!)
FWIW, looking back at my notes, it appears I already _knew_ this was broken in the old mingw headers; ...
It's a pity that the old ("classic") MinGW system is no longer maintained. It looks like you have to use MSYS2/MinGW-w64 to build under Windows with GNU tools nowadays.
While we're at it, do you have any information about the maintenance of the old MinGW toolchain? The last time I checked I could still download the "latest" version (i.e. my old status) with `mingw-get`, but it's probably no longer possible to install the toolchain from scratch. Their website is (was) gone. What do you think, should we remove instructions on building with "classic" MinGW from our docs?
External testing with a small app would be really helpful, Ian. Feel free to post your findings as an Issue on GitHub, bugs, unexpected behavior, missing features, etc. . I am not a regular tablet/pen user, and my old Wacom PTH-450 does not get any driver support port by Wacom anymore, so I can't test it on my ARM64 machine.
[...] here's the tricky bit: I can use the mingw64 tools to build 32-bit Windows code, but it turns out that the version of the mingw64 tools I have implements C++ threads as pthreads, and does this on Windows by wrapping winpthreads.
Now, I'm not using C++ threading at all in my code, but the compiled exe seems to be dragging it in at link time anyway.My older "standalone" machines don't have any winpthread DLL of course, so then the code won't run. Agh!
There's ostensibly some compile / link time flag (e.g. "-no-pthread" or something, forget the details) that's supposed to help dodge that issue, but it didn't seem to work for me. The other option seems to be to download and static-link a winpthread stub, but I've not tried that yet.
Anyway, the upshot is that I can build a 32-bit Windows version to test, using the mingw64 tooling, but I can't currently run the resulting binary on the machines where I can test it...
(And, FWIW, 64-bit binaries built with that mingw64 tooling are similarly afflicted when subsequently run on Win64 machines that do not have winpthreads - which is most of them,,,)
Finally, my SOLUTION (off the top of my head, and IIRC): I assume you are using linker flags "-static-libgcc -static-libstdc++" anyway. You can add "-static" after these flags, and it "magically" works to link everything statically, as far as possible. I believe I'm doing it like this in the first CMake execution:
$ cmake -G "..." -D CMAKE_EXE_LINKER_FLAGS_INIT="-static-libgcc -static-libstdc++ -static" ...
and this seems to do it. Note that I didn't try if "-static" alone works, and I don't know if any of this has any notable side effects (except executable size, of course).
On 6/22/26 14:45 schrieb 'Albrecht Schlosser' wrote:
Finally, my SOLUTION (off the top of my head, and IIRC): I assume you are using linker flags "-static-libgcc -static-libstdc++" anyway. You can add "-static" after these flags, and it "magically" works to link everything statically, as far as possible. I believe I'm doing it like this in the first CMake execution:
$ cmake -G "..." -D CMAKE_EXE_LINKER_FLAGS_INIT="-static-libgcc -static-libstdc++ -static" ...
and this seems to do it. Note that I didn't try if "-static" alone works, and I don't know if any of this has any notable side effects (except executable size, of course).
I should add that I didn't find a way to build FLTK DLL's with similar flags. If I set "CMAKE_SHARED_LINKER_FLAGS_INIT=..." I get lots of linker errors (multiply defined symbols or whatever). I gave up, but if anybody can help, that would be appreciated.
And, FWIW, this is not an issue if you use the Visual Studio to build.
On Monday, 22 June 2026 at 13:53:10 UTC+1 Albrecht-S wrote:
On 6/22/26 14:45 schrieb 'Albrecht Schlosser' wrote:
Finally, my SOLUTION (off the top of my head, and IIRC): I assume you are using linker flags "-static-libgcc -static-libstdc++" anyway. You can add "-static" after these flags, and it "magically" works to link everything statically, as far as possible. I believe I'm doing it like this in the first CMake execution:
$ cmake -G "..." -D CMAKE_EXE_LINKER_FLAGS_INIT="-static-libgcc -static-libstdc++ -static" ...
and this seems to do it. Note that I didn't try if "-static" alone works, and I don't know if any of this has any notable side effects (except executable size, of course).
Thanks Albrecht - I'll give these various ways a try, see what might work "best" for me right now...
I should add that I didn't find a way to build FLTK DLL's with similar flags. If I set "CMAKE_SHARED_LINKER_FLAGS_INIT=..." I get lots of linker errors (multiply defined symbols or whatever). I gave up, but if anybody can help, that would be appreciated.
Yup - fortunately I don't use the DLL all that often, so that's OK in the short term.
But I will need the DLL for a thing I have coming up, so this maybe get tricky...
And, FWIW, this is not an issue if you use the Visual Studio to build.
Which is fine until I need the DLL build, as I will probably have to a load a few DLL's that weren't built with VS, and the C++ ABI is "broken".
It's annoying though, since this is all to make the C++ threads work - which I will not be using.It'd be handy if there were some way to tell gcc not to incorporate that C++ threads capability
- though I tried asking for an "older" C++ level and that did not seem to help.
"1. Use the Win32 Threading Model The most effective method is to switch from the POSIX threading model (which requireslibwinpthread) to the native Windows threading model. This is achieved by using thewin32variant of the MinGW-w64 toolchain.
Set the C++ compiler to the win32 variant:
CXX=/usr/bin/i686-w64-mingw32-g++-win32(for 32-bit) or the corresponding 64-bit path.Alternatively, in newer MSYS2 environments, ensure you are using the UCRT64 or MINGW64 shell which may default to different threading models, but explicitly using the win32 variant guarantees no POSIX pthread dependency."
I can't confirm the latter because I tried it (see emphasis on "may default", set by me), but I didn't know the former. This looks very similar to cross-compiling, but maybe it's *just that*. I'll give it a try, but not right now. Feel free to do it yourself and to report back what you find.
Method 2 mentions "-static-libgcc
-static-libstdc++", but we
knew that.
The 3rd method is (similar to) what I also suggested above:
"3. Manual Removal of Import Libraries (Advanced) If the above methods fail (particularly with newer GCC versions in MSYS2 where
-staticforces all libraries to be static):
Locate the MSYS2 installation directory (typically
C:\msys64\mingw64\lib).Delete or rename
libwinpthread.dll.aandlibpthread.dll.a(the import libraries).This forces the linker to fail if it tries to dynamically link
libwinpthread, but allows static linking if the static archivelibwinpthread.ais available and linked manually via-Bstatic -lwinpthread -Bdynamic. However, using the win32 toolchain variant is the recommended and cleaner approach."
I'm not sure if I posted this earlier somewhere, maybe they found my own advice? ;-)
Anyway, method 1 is certainly something we could try. It should
be easily doable with CMake and looks clean and well supported
(obviously used together with "-static-libgcc
-static-libstdc++").
I also don't remember if I ever tried "-Bstatic -lwinpthread -Bdynamic"
instead of "-static" in my previous
suggestion. Would this help to link the shared FLTK libs (DLL's) ?
If this worked w/o renaming the winpthread import libs this would really be "nice". Let's try!
here are a few results from using the "built-in" AI of the `brave` browser (https://search.brave.com).
"1. Use the Win32 Threading Model The most effective method is to switch from the POSIX threading model (which requireslibwinpthread) to the native Windows threading model. This is achieved by using thewin32variant of the MinGW-w64 toolchain.
Set the C++ compiler to the win32 variant:
CXX=/usr/bin/i686-w64-mingw32-g++-win32(for 32-bit) or the corresponding 64-bit path.Alternatively, in newer MSYS2 environments, ensure you are using the UCRT64 or MINGW64 shell which may default to different threading models, but explicitly using the win32 variant guarantees no POSIX pthread dependency."
I can't confirm the latter because I tried it (see emphasis on "may default", set by me), but I didn't know the former. This looks very similar to cross-compiling, but maybe it's *just that*. I'll give it a try, but not right now. Feel free to do it yourself and to report back what you find.
Method 2 mentions "
-static-libgcc -static-libstdc++", but we knew that.The 3rd method is (similar to) what I also suggested above:
"3. Manual Removal of Import Libraries (Advanced) If the above methods fail (particularly with newer GCC versions in MSYS2 where
-staticforces all libraries to be static):
Locate the MSYS2 installation directory (typically
C:\msys64\mingw64\lib).Delete or rename
libwinpthread.dll.aandlibpthread.dll.a(the import libraries).This forces the linker to fail if it tries to dynamically link
libwinpthread, but allows static linking if the static archivelibwinpthread.ais available and linked manually via-Bstatic -lwinpthread -Bdynamic. However, using the win32 toolchain variant is the recommended and cleaner approach."
[...]
I also don't remember if I ever tried "
-Bstatic -lwinpthread -Bdynamic" instead of "-static" in my previous suggestion. Would this help to link the shared FLTK libs (DLL's) ?If this worked w/o renaming the winpthread import libs this would really be "nice". Let's try!
$ find /mingw64 -name '*pthread*.dll.a' /mingw64/lib/libpthread__RENAMED__.dll.a /mingw64/lib/libwinpthread__RENAMED__.dll.aThis needs to be done only once, unless you update your MSYS2 installation.
$ ldd bin/*.exe bin/test/*.exe | grep -iv /c/WINDOWS/
bin/fltk-options-cmd.exe:
bin/fltk-options-shared.exe:
libfltk.dll => /c/git/fltk/master/build/msys2-mingw64/bin/libfltk.dll (0x7ffefc530000)
bin/fltk-options.exe:
bin/fluid-cmd.exe:
bin/fluid-shared.exe:
libfltk_z.dll => /c/git/fltk/master/build/msys2-mingw64/bin/libfltk_z.dll (0x7fff1cce0000)
libfltk_images.dll => /c/git/fltk/master/build/msys2-mingw64/bin/libfltk_images.dll (0x7fff0a630000)
libfltk.dll => /c/git/fltk/master/build/msys2-mingw64/bin/libfltk.dll (0x7ffefc530000)
libfltk_png.dll => /c/git/fltk/master/build/msys2-mingw64/bin/libfltk_png.dll (0x7fff0c880000)
libfltk_jpeg.dll => /c/git/fltk/master/build/msys2-mingw64/bin/libfltk_jpeg.dll (0x7ffefe280000)
bin/fluid.exe:
bin/test/CubeView.exe:
...
bin/test/handle_keys.exe:
bin/test/hello-shared.exe:
libfltk.dll => /c/git/fltk/master/build/msys2-mingw64/bin/test/libfltk.dll (0x7ffefc530000)
bin/test/hello.exe:
bin/test/help_dialog.exe:
...
bin/test/pixmap.exe:
bin/test/pixmap_browser-shared.exe:
libfltk_images.dll => /c/git/fltk/master/build/msys2-mingw64/bin/test/libfltk_images.dll (0x7fff0a630000)
libfltk.dll => /c/git/fltk/master/build/msys2-mingw64/bin/test/libfltk.dll (0x7ffefc530000)
libfltk_png.dll => /c/git/fltk/master/build/msys2-mingw64/bin/test/libfltk_png.dll (0x7fff0c880000)
libfltk_z.dll => /c/git/fltk/master/build/msys2-mingw64/bin/test/libfltk_z.dll (0x7fff1cce0000)
libfltk_jpeg.dll => /c/git/fltk/master/build/msys2-mingw64/bin/test/libfltk_jpeg.dll (0x7ffefe280000)
bin/test/pixmap_browser.exe:
bin/test/preferences.exe:
...
Step 8: please report your results, all feedback from all users (not only from Ian) would be appreciated. Thanks in advance.
On Wednesday, 24 June 2026 at 14:20:24 UTC+1 Albrecht-S wrote:
Step 8: please report your results, all feedback from all users (not only from Ian) would be appreciated. Thanks in advance.
Thanks Albrecht - that all looks great!
I haven't had a chance to do any testing, and might not for a bit - been tied up in "meetings" the last two days, and probably tomorrow (at least) as well... Sorry.
I'll try to test some more options, and ...
$ find /mingw64 -name '*pthread*.dll.a' /mingw64/lib/libpthread__RENAMED__.dll.a /mingw64/lib/libwinpthread__RENAMED__.dll.a
cmake .. -G "Ninja" \ -D CMAKE_EXE_LINKER_FLAGS:STRING='-static-libgcc -static-libstdc++ -l:libwinpthread.a -Wl,--exclude-libs,libgcc_eh.a' \ -D CMAKE_SHARED_LINKER_FLAGS:STRING='-static-libgcc -static-libstdc++ -l:libwinpthread.a -Wl,--exclude-libs,libwinpthread.a -Wl,--exclude-libs,libgcc_eh.a' \ [...]Replace Ninja with the generator of your choice, and add other switches as needed.
cmake .. -G "Ninja" \ -D CMAKE_EXE_LINKER_FLAGS:STRING='-static-libgcc -static-libstdc++' \ -D CMAKE_SHARED_LINKER_FLAGS:STRING='-static-libgcc -static-libstdc++' \ [...]As above, replace Ninja with the generator of your choice, and add other switches as needed.