Disclaimer

Everything I hacked/scripted in order to be able to compile UNIX projects on Windows with MinGW GCC in a Cygwin environment is provided here because I know it might help some people to Get It Working but is provided without warranty. I personally used it on more than 10 C++ projects so at least it Worked For Me. If you need any help: <tsuna at lrde dot epita dot fr>

Problems

* Windows shell don't deal with Windows paths properly, e.g. running: C:\Qt\bin\moc.exe will result a in a /bin/sh.exe: c:Qtbinmoc.exe: command not found * If you use MinGW in a Cygwin environment, MinGW GCC will not understand paths such as -I/home/build/foo/includedir * GNU Make 3.81 will be confused by colons, eg you can't write a rule: C:\some\target: dependencies The 2nd point might sound weird. Why would one want to use MinGW GCC in a Cygwin environment? Simple: we don't want to deal with the commercial licence of Cygwin (in fact of cygwin.dll). We could use the flag -mno-cygwin but we want to make 100% sure the binary produced is compatible with code compiled by MinGW GCC so we better stick to MinGW. The compiler are not exactly identical and overall it is much better to use MinGW GCC. Now why not use MinGW MSYS then? We need many tools in our environment that are readily available in Cygwin. Cygwin is thus a much more comfortable build environment then MSYS.

How to handle the problems listed above?

I wrote a set of scripts that wrap the MinGW toolchain so that it works transparently from within Cygwin. It mainly consists of a Perl script that is used by GNU Make instead of /bin/sh.exe. And until GNU Make 3.82 is released, you must recompile a patched version of GNU Make 3.81.

How to make-it-working-in-5mins?

Let's make it simple: run install_build_slave.sh It will do everything for you. It will download 2 scripts (my_shell.pl and win_wrapper.sh) and create symlinks in ~/bin. You MUST add $HOME/bin first in your PATH. The scripts assume that you have MinGW installed under C:/mingw and Cygwin installed under C:/cygwin. If you installed them somewhere else, it will be fairly simple to change the scripts. The script win_wrapper.sh also assumes you have ccache installed. If you don't, apply this change: - exec ~/bin/my_shell.pl C:/cygwin/bin/ccache $prog "$@" + exec ~/bin/my_shell.pl $prog "$@" You also need to patch your GNU Make 3.81 (until 3.82 is released).

Patching GNU Make 3.81

Instructions: cd /tmp wget http://ftp.gnu.org/pub/gnu/make/make-3.81.tar.gz tar xfz make-3.81.tar.gz cd make-3.81 PATH=/usr/local/bin:/usr/bin:/bin ./configure patch -p1<make-3.81-cygwin.patch patch -p0<make-3.81-cygwin_MAKE_expansion.patch PATH=/usr/local/bin:/usr/bin:/bin make PATH=/usr/local/bin:/usr/bin:/bin make install (Yes: apply the patches after running configure)

What about Microsoft Visual C++?

I also wrote a set of patches, scripts and hack in order to be able to transparently use the Microsoft compiler with autotools-based UNIX projects compiled on Cygwin. They are not provided here but if you need any help, drop me a mail and I'll try to find some time to write a page similar to this one but for VC++. If I had more time I would actually release a more serious and complete set of tools to deal with QMake and with issues related to Windows builds of UNIX projects. If only I had more free time in my hands... << Back to Autotroll << Back to TsunaNET.net