During my time programming, I often find a lot of the information and help given is based on two assumptions: if you are compiling on Linux, then you are using GCC, and if Windows is your system of choice, you will being using some form of MSVC. Typically I like to be different and have always favored GCC even on my Windows system, so I am jotting down a few instructions on how to set up MinGW (GCC and a few other tools ported to Windows) and MSys so they can act just like a terminal would under Linux allowing you to ./configure && make && make install to your hearts content!
- Head over to http://nuwen.net/mingw.html where a very nice man grabs the latest stable GCC, compiles it for Windows and packages it along with many useful libraries such as boost, freetype 2, zlib, SDL
- Click on his download link, and follow his really simple How To Install guide NOTE If, like me, you choose not to have all your programming sitting on the root of your C: drive, make sure to alter the path to wherever you choose to install MinGW in the PATH environment variable too
So with MinGW installed, we now have a compiler that can be used by quite a few IDEs, but most makefile scripts will still find themselves confused by the Windows environment, so we have to provide them with a n environment that closer resembles the *nix setup they require.
- Head over to http://sourceforge.net/projects/mingw/files/ and download the latest MSys Installer (at time of writing that’s 1.0.11) NOTE You should look in ‘MSYS Base System’ folder of the ‘View All Files’ section to find it
- Run the installer, agree to the license & use
- Again, select a folder you want to install it to, no spaces
- Once the files have unpacked themselves, you should get a console window pop up, confirm that you want to continue with the post install by typing y and hitting enter
- You should have MinGW installed, so again press y and hit enter
- Type in where you installed MinGW to, the default is simply c:/mingw but for me this would be c:/programming/tools/mingw NOTE Yes those are meant to be forward slashes!! Careful!!
- Read the install notes and user guides if you want, else just untick the boxes and enjoy your new MSys!!
A couple of gotchas to take into account now.
Firstly, it seems the sed.exe packaged with MinGW gets awfully confused with Windows line endings. Best thing to do is head to your /mingw/bin directory and delete it. The sed.exe from MSys works correctly with file endings and that will take over.
Secondly, if you plan to use the SDL library at all, the sdl-config script need a quick modification. If you head to your /mingw/bin directory and open sdl-config in a text editor, line 3 should by something like prefix=/c/temp/gcc/dest edit that so it simply reads prefix=/mingw and save.
Lastly, just remember from now on to add –prefix=/mingw to any configure script you run and you should be good to go.
No go and enjoy ./configure –prefix=/mingw && make && make install on Windows to your hearts content.