Let\'s say I have an application which I compiled under cygwin, and I want to distribute that application without having the user to install cygwin. Would it be enough to packag
Does your application actually need any Cygwin provided Posix emulation? If not, you can compile it with the -mno-cygwin flag and it won't depend on cygwin at all, but will be a native Windows application. Often, you only need a real shell (bash) to configure and build your application, but you don't actually need the Posix functionality of Cygwin.
Another alternative is MSYS + MinGW, which is a light-weight fork of Cygwin. This provides a compilation environment which produces native Windows apps by default.
A third option would be to use the MinGW compilers from Cygwin itself. They should be available via the normal Cygwin package manager. Then you would configure the project for a cross-compile using the MinGW compilers.
Normally, yes. Be sure to install the Cygwin DLL in a public location though (Windows\System32), this DLL behaves very badly when multiple versions of it are loaded on the same machine.
Things have changed. The Cygwin libraries are now under the Lesser GPL (v3), which makes it possible to bundle them with applications that fall under a wide range of licenses, from FOSS to proprietary.
What stands in the way is that the POSIX emulation in Cygwin takes things a little too far from the perspective of native Windows applications.
This is where my Cygnal project comes in. Cygnal stands for CYGwin Native Application Library: it is a drop-in compatible fork of Cygwin which changes, or in some cases simply re-configures, the behaviors of certain functionality in order to conform with native conventions of the Windows platform.
A basic "Hello, World" Cygwin program requires two libraries. A GCC run-time called cyggcc_s-1.dll
and the Cygwin DLL cygwin1.dll
. The Cygnal project provides a replacement for the latter. (A 32 bit build is available for download).
One glaring area of incompatibility between the Cygwin POSIX view of the world and Windows is path handling. The Cygwin view of the filesystem is through a fake /
root directory, and its own internal "mount table" which provides spaces like /cygdrive
, /proc
and /dev
. Cygnal does away with all that. Paths are Win32 paths. The current working directory behaves like the Windows current working directory. Drives are associated with current directories, and drive relative paths like D:foo.txt
work under Cygnal. Under Cygnal, /dev
and /proc
are still available: they are accessed as the special prefixes dev:/
and proc:/
. It is not permitted to chdir
into these: that would not be native! Under Cygnal, if you chdir
to D:\wherever
then your current drive is the D
drive, and the paths /foo
or \foo
refer to D:\foo
. Cygwin's master POSIX root directory is gone.
Yet, with Cygnal, you can continue to use the POSIX functionality, making it possible to develop cross-platform programs that have less code that is switched based on platform, compared to maintaining a port using MinGW or Microsoft Visual C/C++.
For example: you can write a Win32 console application using VT100 codes and termios
. The same code will run on Unixes. No need to use the Win32 console API on Windows and VT100/termios
on a POSIX system.
Another example: for threading, you can just use POSIX threads. pthread_create
to start a thread, pthread_mutex_lock
to lock a mutex and so on. Your program doesn't need a portability abstraction for threads which translates to Win32 or POSIX; you just use the POSIX and that's it.
The uname
function in Cygnal reports the sysname
with a CYGNAL
prefix rather than CYGWIN
. By means of this, your program can tell that it's running on Cygnal rather than Cygwin (or any other POSIX platform). Thus you can make any necessary adjustments: for instance, if your program needs /dev/null
, on Cygnal it can look for dev:/null
instead.
You could try to compile everything as static. That should allow you to run everything without the need of the the libs (since they are already in your binary). But this will also mean that it might not work an all platforms if cygwin would need a different or newer dll.