For a newer version of this document, see the Introduction section

Setting up a compiler

Unfortunately Eclipse only provides the Integrated Development Environment (IDE) but it is missing the actual compiler. To install a compiler, please follow the instructions for your operating system.

Windows compiler

Windows doesn't come with a build-in compiler. You could try to install Visual Studio, but it is tricky to get that working with Eclipse. Therefore we will install MSYS. MSYS is part of the MinGW suite, which provides free development tools for Windows.

You will have to follow these 4 steps:

  • Download and install MinGW

  • Download and install MSYS

  • Set your path environment variable

  • Restart Eclipse if it was started.

MinGW

First, you need to download MinGW. You can either click through the websites mentioned above or go directly to the MinGW download area. Look for the Package "Automated MinGW Installer". There, download the file ending in .exe. The file name should be something like "MinGW-5.1.4.exe". You can also download MinGW Version 5.1.4 from the link given here.

You may also download an older version, and follow the instructions given in the section called “Older Instructions”:

Most of the options in the MinGW 5 installer are pretty straightforward. I will point out some of the more tricky options.

The first one of such options is which "MinGW" package to install. Any of those should work just fine, but I would recommend Current.

Figure 1. MinGW 5 install

MinGW 5 install

MinGW will ask which components to install. Either select All or at least make sure that you have the g++ compiler checked. This is needed for C++ support.

Figure 2. MinGW 5 install (2)

MinGW 5 install (2)

When asked for the install folder, please do not change it. You will have a lot of trouble later on, especially if you chose a path that contains spaces.

Figure 3. MinGW 5 install (3)

MinGW 5 install (3)

That's already it for MinGW. There are two more steps: MSYS and the Environment Variables.

Checkpoint: To test if everything worked, please reboot. Then open up a terminal. (Start/Run, type CMD). Try these commands:

gcc --version

should print the version of gcc. If you get a "File not found", try logging out and logging back in, or even rebooting your computer. If it still does not work, you have not installed MinGW correctly. You may also need to set your environment variables manually (see below).

g++ --version

should print the version for g++. You did select the "g++ compiler" I hope. If not, install again!

GDB (optional!)

This section is completely optional. You may skip it and go directly to the section called “MSYS”.

If you want to use the debugger, you may have to install it separately. This is the case with MinGW 5.0.2, it may be different in other versions. Download it from the same page, look for a package starting with gdb and ending with .exe. At the time of this writing (Apr 29) the current version was "gdb-5.2.1-1.exe". Install (double-click) that .exe, select all the default options (make sure you select the same MinGW directory as you did during the MinGW install).

I have received a report that gdb-6.3-2 does not work. So I would advise using the older version or waiting for a newer one.

Checkpoint:

gdb --version

should print the gdb version. This is optional.

MSYS

Unfortunately MinGW is not enough. We also need the MSYS tools from the same download page. Go there again, to the "Current" section and look for "MSYS Base System". Again, look for the file ending in .exe, as this time: "MSYS-1.0.11.exe". You may have to expand the "Release Candidate" section. Or you may use the link here to MSYS-1.0.11.exe. Download it and start it. You should get a window like this:

Figure 4. MSYS install

MSYS install

If you accept all the default options, after a while there should be a black and white window, similar to this:

Figure 5. MSYS asking for postinstall

MSYS asking for postinstall

To continue the install type in y and then Enter. The next question reads like this:

Figure 6. MSYS asking for MinGW

MSYS asking for MinGW

Which you can also answer with y Enter. The next question is a little bit more tricky:

Figure 7. MSYS asking for path to MinGW

MSYS asking for path to MinGW

What they want to know is where you installed MinGW to and that you replace all backward slashes (\) by forward slashes (/). If you followed the instructions, the answer here will be:

C:/MinGW

Caveat: If you have not used the default paths, but instead have installed MinGW in a different location, such as C:/Program Files/MinGW, where the path contains spaces and / or is longer than 8 characters you may have to replace that particular path component with its DOS short pathname, such as C:/PROGRA~1/mingw.

Caveat2: The installer may be case sensitive. Please make sure you have written MinGW in the same capitalization as during your first install, in some cases you will have to enter c:/mingw (note capitalization!).

The very last question just asks you to press a key:

Figure 8. MSYS installing correctly

MSYS installing correctly

Where you can press any key you like to continue. Setup will come back and ask you if you want to read a welcome note and the README file. You probably don't want either one, but it does not hurt to look. Anyways, once you hit "Finish" you are done with the setup. Now you have to set up your Path environment variable.

Figure 9. MSYS is done

MSYS is done

Environment Variables

The next thing you need to do is set up your Path environment variable. To do so, right-click on My Computer and select Properties. Then, select the Advanced tab. There should be a button called Environment Variables.

Figure 10. Finding Environment Variables (Windows 2000)

Finding Environment Variables (Windows 2000)

Figure 11. Finding Environment Variables (Windows XP)

Finding Environment Variables (Windows XP)

In the environment variables, there are two sections, one for the local user (you) and one for the system. Depending on whether you want the paths to be set for everyone, or for you, do one of the following:

Warning: I had reports of people deleting their existing Path environment variable! Please be very careful when editing an existing value! By default, Windows has the whole line selected, resulting in overwriting what was in there!

If you want to set it for everyone, look for the variable Path in the section System variables. Click Edit. There should already be some stuff in there, append ;C:\msys\1.0\bin;C:\mingw\bin (or your appropriate paths) to it, and select OK multiple times. Please make sure that you do not overwrite what was in there!

If you just want to set it for you, look for Path in the upper section. It is very likely not there yet. So select New... and enter C:\msys\1.0\bin;C:\mingw\bin (or your appropriate paths). Then select OK multiple times. Again, if there was a setting before, do not delete it, but rather append your path!

There seems to be a problem with a very long PATH environment variable on some systems. According to reports, Eclipse will fail to compile and build, where as compiling and building from a command window may work fine. In this case, try to prepend the path to MinGW and MSYS rather than appending it.

Congratulations. Now you have a complier and make set up on your computer. Continue with the section called “Setting up Eclipse”.

Checkpoint: Open up a command terminal (cmd) and type:

make --version

This should work now. If not, you have either not installed MSYS correctly or not set your path environment variable. Also, try logging out and back in.

Linux / Unix Compiler

In most Linux and Unix distributions the compiler is already installed. Check if you can run

g++ --version

and either

make --version

or

gmake --version

If both of them (g++ and either make or gmake) work then you are already done. If not, please install those. This may be very different depending on which Linux or Unix distribution you have. Install the tools and continue with the section called “Setting up Eclipse”.

Mac OS X Compiler

On Mac OS X you can also try the commands explained in the section called “Linux / Unix Compiler” to check if you have the necessary tools installed. If not, you will need to install the developer tools. They are either on one of your Mac OS X CDs that came with your computer, or you can download them at: Apple's developer connection.

For a newer version of this document, see the Introduction section

Home

HowTo