Thursday, February 17, 2011

Across and Back Again

As you may be aware, last summer I added cross-compiling support to cygport, resulting in a new 0.10 series. The results so far have been quite promising, with cygwin-based cross-toolchains now available for the following targets:

  • MinGW (i686-pc-mingw32), with the basic packages available here pending an ITA, and many more in Ports
  • MinGW-w64 (i686-w64-mingw32 and x86_64-w64-mingw32), already in the distro
  • Linux x86 (i686-pc-linux-gnu) and x64 (x86_64-pc-linux-gnu)
  • Solaris 10 x86 (i386-pc-solaris2.10) and SPARC (sparc-sun-solaris2.10)
  • Solaris 11 x86 (i386-pc-solaris2.11)
  • AVR microcontrollers (avr)
With this improvement to cygport, cross-compiling from Cygwin comes with the ease you would expect from a Linux distribution.

This week, I decided it was time to turn things around and make it easier to cross-compile to Cygwin as well. To that end, I have created a minimal Linux-to-Cygwin cross-compiler toolchain for Fedora Linux. Under my "fedora-cygwin" (sub)project, I have posted .spec files and patches to SourceForge git and RPMs for both ix86 and x86_64 to the File Release area. For now it is necessary to manually download and install the RPMs until I have the chance to figure out how to setup a yum repository.

While these packages are mostly based on the work of the fedora-mingw project, there are important differences. I'll admit that these are my first RPM spec files, so I'll gladly take constructive suggestions for improvement, or better yet, git patches. Furthermore, these have yet to be tested beyond building themselves. If you do find these useful, or discover any problems, please let me know through the Cygwin Ports mailing list for now.


Robert said...

You are all fantastic, you's that work on Cygports. WSUS is gone, Co-Linux is er not excellent. Cygwin is fantastic.

samw said...

Wow, wow, wow!

But I'm a real noob, may I ask a question?
does the mingw port mean you can compile so that the executable has no (cygwin) dependencies, like in real mingw, (so there is no difference between them)?
if yes, how do I do that?
I'm sorry for my silly question but I really need to know.
thanks again.

Yaakov said...


Compiling with the i686-pc-mingw32 cross-gcc will provide similar results to compiling within a MinGW environment with their gcc.

The difference is, that when doing so from within Cygwin, you are *cross*-compiling. Not all build systems or packages support cross-compiling, so it won't work for everything, but for many packages it is feasible.

How to cross-compile in general depends on the package in question, and is beyond the scope of a blog comment. The most common build system is autotools, and that can be as simple as adding "--build=i686-pc-cygwin --host=i686-pc-mingw32" to your configure flags.