Compiling under Cygwin

27 views
Skip to first unread message

ed.vi...@gmail.com

unread,
Nov 9, 2022, 9:09:12 AM11/9/22
to fltk.general
Hello

When I compiled FLTK 1.3.8 under Cygwin, using gcc (--enable-cygwin), the compilation of fluid/ExternalCodeEditor_WIN32.cxx failed with _snprintf() unknown. I removed the leading underscore and things worked.

Cheers
Ed

Ian MacArthur

unread,
Nov 9, 2022, 11:08:56 AM11/9/22
to fltk.general
On Wednesday, 9 November 2022 at 14:09:12 UTC Ed wrote:
Hello

When I compiled FLTK 1.3.8 under Cygwin, using gcc (--enable-cygwin), the compilation of fluid/ExternalCodeEditor_WIN32.cxx failed with _snprintf() unknown. I removed the leading underscore and things worked.

Ed,

Hmm, OK. 
TBH I haven't used cygwin much myself in years (initially because the runtime code it produced was, unexpectedly, way slower than the same code compiled with mingw, then latterly because I kept getting into weird cygwin DLL version issues and not being able to find a way out...)

Anyway, at some point in the past, for me cygwin had a header set that enabled the MS-style underscore names to be used and it worked fine (though IIRC both cygwin and mingw are also generally happy with Posix-style no-underscore names too.)

That compatibility may well have changed in the meantime - there did seem to be some cygwin changes I saw that looked to be motivated by some sense of Posix-purity, eschewing all MS-ness, but which were perhaps more a triumph of ideology over practicality, so this might well be something that used to work but has now been "improved" such that it no longer does...

Out of curiosity, do you actually need to use the cygwin layers and the DLL, or can you just use mingw? Were you only trying cygwin out of interest?


ed.vi...@gmail.com

unread,
Nov 10, 2022, 2:15:56 AM11/10/22
to fltk.general
Hi

Thanks for the reply. I do not need Cygwin per se. If I can get it to complete with mingw, that might be better anyways, if it is faster nd can run without Cygwin installed.

Personally, I only use Linux and Mac OS but needed to get my app to work under Windows.

Cheers
Ed

Ian MacArthur

unread,
Nov 10, 2022, 3:48:53 AM11/10/22
to fltk.general
On Thursday, 10 November 2022 at 07:15:56 UTC Ed wrote:
Hi

Thanks for the reply. I do not need Cygwin per se. If I can get it to complete with mingw, that might be better anyways, if it is faster nd can run without Cygwin installed.

The "key" difference between cygwin and mingw is the "OS API" they expose to your code - cygwin uses it's DLLs to wrap up various services (e.g. threads, fork, etc) so that they appear "Posix-like", the idea being to allow *nix code to be compiled for Windows "as-is".
The mingw tools expose the Win32 APIs instead, in effect emulating what MS own tools do.

So... If you have only used fltk-isms in your code, it should Just Compile Anywhere, and all is well, cygwin and mingw and VS become "equivalent" at that point.

If you have used any (platform specific) Posix-like features in your code, then cygwin may still be your best bet - the alternative is to #ifdef around the portability issues and drop in the equivalent (but inevitably different) MS feature.

That cygwin emulation costs you a bit (from my experience, it was this emulation layer that impacted performance, though the hit was not that great and would likely not matter in many cases.) It also ties you to the cygwin DLL's, and my experiences with that have not been stellar. 
(Things may be better now, but there was a time when many dev tools were being ported from *nix to Windows, and using cygwin. Some ports were well behaved and put their copy of the DLL in a private place, others scattered the DLL around in system folders. Chaos often ensued. I was often unhappy...)
 

Personally, I only use Linux and Mac OS but needed to get my app to work under Windows.

The mingw-cross tools under Linux might be your path of least resistance then? Just build on your Linux host but cross-compiling for Windows. Means you can just use the environment you are familiar with and so on.

Or if you want a "native" Windows setup and mingw is OK for your use-case, I'd probably go for Msys2 (which provides a bash-like shell on Windows) and then use their package manager to install the various tools you are familiar with, but on the Windows machine.


Albrecht Schlosser

unread,
Nov 10, 2022, 11:26:41 AM11/10/22
to fltkg...@googlegroups.com
On 11/10/22 08:15 ed.vi...@gmail.com wrote:
> I do not need Cygwin per se. If I can get it to complete with mingw,
> that might be better anyways, if it is faster nd can run without
> Cygwin installed.
>
> Personally, I only use Linux and Mac OS but needed to get my app to
> work under Windows.

I'm cross compiling FLTK and all FLTK demo programs on Linux using the
MinGW cross tools. The resultant .exe files can be run under `wine` for
testing and on "real" Windows systems (after copying or via network access).

This is at least an option to test Windows builds regularly on a Linux
system. I wouldn't say it's production ready for distribution but that
could be done on a real Windows system (less often).

I'm not sure if this helps you (Ed): we have information on how to set
up the cross build chain with CMake in our README.CMake.txt file, see
chapter "2.7  Crosscompiling".

Reply all
Reply to author
Forward
0 new messages