Hackery: MinGW

For the past month or so, I’ve been porting my Tools and Compression libaries to Windows. I am a strong proponent of developing cross-platform code, so I occasionally like to port somewhat stable code across multiple OSes. Luckily I have access to the big 3: Linux, Windows and OS X.

When developing code, I prefer to avoid GUIs. I’m a vi(m)/make kind of guy, having used these tools since my formative geek years in college. I can work much faster keeping my fingers on a keyboard than switching between a keyboard and a mouse. So, when porting code to the Windows, I’d rather not have to rely on Microsoft’s Visual C++ environment with its GUI and built-in project templates and multi-stage dialog boxes.

I discovered MinGW last month and loaded it, and MSYS, onto my laptop and I haven’t looked back since. It provides a working shell, the gcc compilers and enough of the POSIX/GNU tools that I need to build code. All for free. It is lighter than the venerable Cygwin environment, which I had used in the past, and the programs that the MinGW system builds are not reliant upon any Cygwin DLLs. I can build honest-to-goodness Windows code and not be reliant upon an 3rd party DLLs. Very sweet.

Hackery is not free, however. When running a printf()-riddled test program in the MSYS shell, the output is not flushed to the screen after every newline character, like it should. So, when testing multiple 10MB compression runs, I have to wait for the entire process to finish before seeing any of the results instead of seeing each result individually as it completes. This is annoying, but it is not a show stopper. It’s a testing limitation.

Prior to the MinGW port, I did download and install Visual Studio 9.0 Express Edition. I’m not sure if the MinGW builds rely on any libraries and/or include files from this installation. If not, I’d just as soon remove the bloatware from my system and move on.

Update:

I was able to write a mingw_printf() function that calls vprintf() and fflush() to force flush the output if there is a newline character in the format string. It also looks like MinGW supplies its own set of include files for development. I think I can uninstall Visual Studio and not feel the pinch.

Comments are closed.