Cygwin

From OSDev.wiki
Jump to navigation Jump to search

"Cygwin" is two things. For one, it is a DLL implementing most of the POSIX API on top of Windows, so to ease porting GNU/Linux tools to Windows.

But in a wider sense it is also a setup.exe for downloading and installing a wide collection of such ported tools on your Windows machine, including a bash shell, GCC toolchain, Apache, PostgreSQL, and many other valuables. As such, it enables OS developers working with Windows to use the same toolset as OS developers under Linux.

Using Cygwin

The Cygwin installer offers to add an icon to your start menu and / or desktop. By clicking on that, you get a console which actually is a bash shell. /cygdrive/<letter>/ under Cygwin is equivalent to <letter>:\ under Windows.

By default the Cygwin installer does not install GCC. Just restart the installer and select GCC (and, if you want to do C++, G++) from the "devel" group. Also download binutils as many applications require this. (And whatever other tools you want; recommended minimum is make, rcs, cvs, and openssh.)

After the installer finished, you just pick up the GCC manual from gcc.gnu.org (or do 'info gcc' in the Cygwin shell) and be a happy camper.

Cygwin Known Problems

Some applications may not compile with Cygwin with such errors as "default file extension - cannot create executables" or "cannot find crt2.o" or "cannot find -lmingw".

The reason for these messages is that it appears some utilities installed after the "core" Cygwin files, mess up Cygwins pointers to it's default libraries. The solution is to start Cygwin Setup and select the following four packages to re-install:

      libs/mingw-runtime
      devel/gcc-mingw-core
            gcc-mingw-gpp++
            mingw-runtime

Click on 'Keep' next to each package to change the option to 'Re-install'. Then click next, next etc.. and the libraries will be re-installed.

Re-installation can be sped up by selecting "Install from Local Directory" rather than "Install from Internet" when Cygwin setup starts. This will use packages already on your computer, installing from the Internet each time will guarantee any updates available are installed.

There is a small chance that Cygwin may 'break' itself after updates, but after following this procedure you should be back in business.

Cygwin beyond OSDev

If you go beyond OS development, there are several caveats regarding Cygwin that make its approach of "POSIX on Windows" less than perfect. Two more refer to Licensing Issues when linking Windows applications using Cygwin:

  • linking to the Cygwin DLL (POSIX API) makes your code fall under the GPL if distributed, and being dependent on the Cygwin DLL being present in a system;
  • linking to the standard msvcrt.dll (Win32 API) leaves the licensing decision in your hands and makes your code independent of the Cygwin DLL. Alas, no POSIX here.

If you intend to use the Cygwin gcc for building software, you should check out the permutations of the "win32" and "no-cygwin" options.

See Also

Articles

External Links