Setting up a FLOSS development environment on Windows

Setting up a Free/Libre/OSS development environment on Windows is surprisingly easy: all you have to do is mix two or thee ingredients, and add salt to taste.

The ingredients you’ll need are a toolchain and an IDE. Depending on the type of programming you want to do, your options vary. If, for example, you want to do GUI programmng, your choices will depend on the GUI toolkit you want to use. Each of them comes with its own tools, a d its own requirements wrt a toolchain.

If, on the other hand, you want to do “core” programming, you have still different options in front of you.

The advantage you have in any of these cases, however, is that in tge majority of cases, the FLOSS tools have good reputations and are, for the most part, portable to other target platforms as well.

Toolchains

There are really only two FLOSS toolchains for Windows: Cygwin and Windows: MingW.

Cygwin

Cygwin is a Linux-like environment on Windows. It consists of a DLL (cygwin1.dll) and a large number of tools, all of which can be installed with a single installer, Cygwin Setup. This installer can be run any number of times, to add parts to the system and/or to update them. Cygwin is quite a bit more than just a toolchain (compiler, assembler, linker and related tools) but provides a complete environment to develop in, even including an X-windows environment. I recommend everyone who is familiar with the GNU system to install Cygwin on their Windows computer.

MinGW

MinGW is Minimalist GNU for Windows. It is a port of the entire toolchain (compiler, assembler, linker and related tools) to Windows and, unlike Cygwin, produces binaries that are native to Windows (binaries produced by the Cygwin toolchain need Cygwin to run). MinGW comes with MSYS, the Minimalist SYStem, which is a fork of Cygwin.

Most FLOSS tools that target Windows are based on the MinGW toolchain, and some ship it with their IDEs. Some don’t, in which case you can download and install it yourself using the MinGW installer, which you can download from SourceForge at the MinGW project page. Note, though, that the automated installed doesn’t necessarily install the latest versions of everything: manual installation instructions can be found here.

GUI Toolkits

There are several well-known FLOSS GUI toolkits available for Windows, most of which are either ports to Windows of well-known GNU/*NIX GUI toolkits, or toolkits that are free implementations of previously known Windows toolkits. I will treat only three in this article, each of which is very well-known and widely used: GTK+, wxWindows and Qt.

GTK+

GTK+ is a GUI framework written entirely in C. It is part of the GNU project and is at the heart of GNOME and the GIMP. It comes with a very interesting tool for GUI designed, called Glade, which generates an XML file that is interpreted at run-time to generate the on-screen GUI. Glade is licensed under GNU GPL, while GTK+ is licensed under GNU LGPL. GTK has bindings for many programming languages, including C++, and has a good reputation, being in-use for many well-reputed applications for several years now. It is under active maintenance by a team of volunteers. Windows ports exist and are also maintained.

Due to the fact that GTK+ is written in C, is part of the GNU project and uses only Free/Libre software, many of the basic building blocks that we tend to take for granted in a C++ environment that comes with the standard library, including the STL, have been re-implemented for GTK+. GTK+ is based on GLib, a low-level “core” library including ADTs and portability wrappers for things such as threads, and event loops; Pango, a text rendering library; Cairo, a 2D graphics rendering library; ATK, an accessibility toolkit. Each of these building blocks can be used separately (though there are dependencies between them).

For new projects written in C that need a GUI, this is probably the best choice for a GUI toolkit: there are many examples, the port to Windows is up-to-date and maintained and the port to most other platforms is up-to-date and maintained as well. The learning curve may be a bit steep to climb at first, but that is true for any full-fledged kit written in C. For new projects written in C++, there are GUI kits that are better suited for C++ development, which we will get to.

To obtain Windows binaries (and sources) of GTK+, you can go to this page for complete instructions.

wxWidgets

The wxWidgets project set out to create a low-cost, portable, open-source, easy-to-use GUI framework for C++ programming, and they have succeeded in doing so. It builds upon the native APIs for Windows and MacOS (though I’m not sure it uses Cocoa), and on GTK+ or Motif on *NIX.

wxWidgets consists of several libraries, including extended implementations of things you might find in the STL. It also contains libraries to handle XML, networking, text rendering, etc. although all this is quite a bit more encapsulated than it is in, for example, GTK+.

For new projects written in C++ that target different platforms, including (for example) smart phones, wxWidgets may be a good choice. I have no experience whatsoever with it, however, so I can neither recommend it, nor recommend not using it. I would suggest, though, that you take a look at wxWidgets compared to other toolkits including its last seciont: “Why You Shouldn’t Use wxWidgets”.

Go to the download page to download and install.

Qt

Now owned by Nokia, Qt was originally the closed-source library on which KDE was based. Qt has grown out of its closed-source roots and is now available under LGPL. It is a complete GUI toolkit written in C++ and ported across several platforms, including embedded ones. It even comes with its own windowing system for embdedded platforms.

Qt consists of its own build system, its own IDE, its own internationalization system, its own GUI design system, a large number of ready-made widgets and a complete set of libraries that do anything from networking to XML parsing, filesystem access, etc. This has, of course, its drawbacks as well as its advantages, but these “own implementations” are generally well-written and generic enough for general use.

Qt pioneered the signals/slots view of the Observer pattern, and uses its meta-object compiler to generate the code necessary to to maintain the signals and slots. Though with modern C++ compilers this is no longer necessary (see the Boost.Signal implementation of signals and slots for proof if you need it) at the time it was a judicious choice and now is only a minor nuisance.

For new C++ projects that need a GUI, this is the GUI toolkit I would personally use: it contains everything you need to quickly develop a GUI around your existing code and can sometimes come in handle to put an app together quickly. Qt’s implementation of the model-view-controller pattern is one of the best I’ve encountered so far, and allows you to completely de-couple the core implementation of your work from the GUI which, to me, is an absolute requirement for creating testable, maintainable software.

You can get the latest version at the Qt page.

Integrated Development Environments

There are several FLOSS IDEs on Windows. Obviously, I won’t count Microsoft Visual Studio Express Edition: it may be free as in beer, but it’s not libre or open source software. It wouldn’t work with either of the two toolchains I mentioned above anyway, btw, unless you have a nac for writing Makefiles and not getting support from your IDE to keep them up-to-date…

The ones I will look at are Code::Blocks, CodeLite, Anjuta, Qt Creator and Eclipse.

Code::Blocks and CodeLite

Right off the bat, I should say I’ve never used either of these two IDEs. They seem to be the IDEs of choice for wxWidgets, though, so I feel I should at least mention them. If you have anything, good or bad, to say about either of these IDEs, leave a comment.

Anjuta

I’ve used Anjuta for GTK development, and for development in C, on Linux (under GNOME) and on Windows. As far as I can tell, there are no recent ports to Windows of this IDE, however. The port that existed a while ago had some stability issues and should not be used in production environments. Under Linux, its behavior is a lot better.

I would not recommend using Anjuta in a FLOSS development environment on Windows. On Linux, as indicated, it’s another story – but that is not the subject of this article.

Qt Creator

While Qt Creator comes with Qt and, as I stated before, Qt is my GUI framework/toolkit of choice for new GUI applications in C++, Qt Creator is by no means my IDE of choice for such applications: although its integration with Qt is, obviously, very good, it assumes (usually correctly) that you’re doing Qt programming and is therefore less well-adapted to general-purpose programming. This may or may not be a problem, depending on whether you want to use the Qt build system and framework for non-GUI applications as well. As I usually don’t do that, Qt Creator is not my IDE of choice for non-GUI applications in a FLOSS development environment.

Eclipse

Eclipse makes no assumptions about anything (or hardly any about hardly anything) and is therefore well-suited for “core” programming as well as GUI programming. Due to its modular architecture, it is possible to extend Eclipse well beyond its roots as an IDE for Java. I have so far seen it used as an IDE for several embedded platforms, as well as for things that didn’t exactly look like an IDE.

For C and C++ programming, there’s an Eclipse plugin called CDT, which you can download from here. It does not come with a toolchain, but detects the presence of both Cygwin and MinGW, if they’re installed in any of the usual locations.

For GUI programming with Qt, there’s an Eclipse plugin that you can get from the Qt website. It looks like a similar plugin for GTK is dead in the water. For wxWidgets, there doesn’t seem to be a plugin, though there is a page on their wiki that explains how to use Eclipse (and suggests to use Code::Blocks in stead).

Personally, due to its completeness and the availability of many, many plugins, I’d go for Eclipse for an IDE in a FLOSS development environment.

Installation

I will consider the installation of two three toolchain/GUI toolkit/IDE combinations here: Cygwin with Eclipse, without a GUI; MinGW with Eclipse, without a GUI, MinGW with Eclipse and Qt, and QtCreator with Qt and MinGW. The installation procedure of each of these is described below.

Cygwin/Eclipse

In order to use Eclipse with Cygwin, you need the CDT plugin for Eclipse, and you need Cygwin to be installed. You can install Cygwin using Cygwin Setup. The installation process is pretty straight-forward. The toolchain is in the Devel category. Install at least g++ and its dependencies. That should include binutils and gcc. You’ll need gdb as well.

Once you have Cygwin installed, you might want to try building a simple “Hello, World!” program to check that everything works. Should not be a problem, but you might as well try.

Eclipse assumes Java (JRE) to be installed. Just go to java.sun.com and git the “Get Java” button if you don’t already have it (which is unlikely, but ye never know). It doesn’t need anything other than downloading and unzipping to run: there’s no installer.

Eclipse works with “work spaces” under which you have “projects” which contain your source code, as mapped on the drive. There’s a plugin for integration with Git (EGit) that you can download and install through Eclipse’s integrated installer.

Eclipse will detect the presence of Cygwin if it’s installed in the standard location.

MinGW/Eclipse

To install MinGW, you can either use the automated installer (hit the download button) or the manual installation procedure. The automated installer is easier to use but the manual installation procedure allows you to get more up-to-date tools. In either case, the tools in the toolchain are the same as for Cygwin.

The instructions for Eclipse are the same as well. You can install both toolchains on your computer and switch between the two if you like. Eclipse will detect them both of they are installed in the usual locations.

MinGW/Qt/Eclipse

Adding Qt to the MinGW/Eclipse mix is a question of installing Qt and installing the Qt plugin for Eclipse. This shouldn’t pose any problems – especially once you have Eclipse and MinGW installed.

MinGW/Qt/Qt Creator

Qt Creator comes with its own copy of MinGW, so you don’t need to install it separately. Just download and install the Qt SDK.

Conclusion

I hope this article has been helpful in selecting the tools for your FLOSS projects. If I’ve missed anything, or if you have any other questions, answers, comments or suggestions, please leave a comment.

Share in top social networks!

About rlc

Software Analyst in embedded systems and C++ programmer. I specialize in systems design, concurrency and language design, and am interested in generic meta-programming and functional programming and their practical applications. I take a pragmatic approach to project management, focusing on the management of risk. I have over a decade of experience as a software professional and a background in science.
This entry was posted in Software Development. Bookmark the permalink.

One Response to Setting up a FLOSS development environment on Windows

  1. rlc says:

    Update: the Windows version of GTK moved – the link has been updated. They now also have an experimental 64-bit Windows version, here

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">