Recently I wanted to compile a quick UDP test program on Windows and be able to ship it as a single stand-alone binary. I’ve compiled the source with GCC on Cygwin, and as you might already know, the executable is dependent on cygwin1.dll. This can be checked with the following command:
$ objdump -p udptest.exe | fgrep cygwin1.dll
It is possible to use the Cygwin development tools to build MinGW applications that do not depend on the Cygwin DLL and only depend on runtime libraries distributed as part of Windows.
The MinGW FAQ provides an answer on how use the Cygwin environment for development, yet generate non-Cygwin-dependant executables.
Adding the line
in /etc/profile before exporting PATH will have the effect that within the Cygwin environment the instance of GCC used is the MinGW version.
Note that the MinGW toolchain is gcc/g++ based but it’s using the WinAPI. If you want to use the UNIX Socket API by using the cygwin headers and libs, you have to supply the Cygwin DLL with your program. If this is not an option, you will need to rewrite specific parts of the project to conform with the winsock API.
Look here for some notes about Windows sockets versus Unix sockets. I did a rewrite by including the winsock2.h header file, like e.g.
I’ve built the executable with
gcc -DMINGW -o udptest udptest.c -lws2_32
and verified the dependencies with
$ objdump -p udptest.exe | fgrep DLL
DLL Name: KERNEL32.dll
DLL Name: msvcrt.dll
DLL Name: WS2_32.DLL
shows that the executable is no longer dependent on the Cygwin DLL.