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

Older Instructions

Sometimes you may not be happy with the current version of a certain program. I have left instructions for the older versions here in case you need them:

Installing the CDT on Eclipse 3.4

Note

This is only required if you did not download the CDT version as described above. Please check if you are able to create a new C++ project (as described in the section called “Hello, World!”) before going through this section!

In the "Help" menu select "Software Updates..."

Figure 28. Select Software Updates... from the menu

Select Software Updates... from the menu

This will show you the list of available software update sites. If you are luck you already have the CDT update site configured. Search for an entry which contains the String "cdt", for example http://download.eclipse.org/tools/cdt/releases/ganymede.

Figure 29. Main Software Update page

Main Software Update page

If there is no site for cdt available, go to "Manage Sites", and you will get a list of sites.

Figure 30. Manage Software Update sites

Manage Software Update sites

Again, search for a site containing "CDT". If there is no site available, add it (using the "Add..." button), adding http://download.eclipse.org/tools/cdt/releases/ganymede (the address may be different in future versions of Eclipse, this is for 3.4!)

Also, make sure the checkbox next to the Address is checked. Otherwise the site is configured, but ignored by Eclipse. Leave this page and go back to the main Software update page.

Expand the CDT site, and find the latest version of the CDT. Make sure you select at least the following:

  • Eclipse C/C++ Development Tools

  • CDT GNU Toolchain Build Support

  • CDT GNU Toolchain Debug Support

  • Eclipse C/C++ Development Platform

Figure 31. Select CDT from the Update Site

Select CDT from the Update Site

The select "Install..."

You will have to confirm the selection with "Finish"

Downloading and installing will take a while. Once its done it will ask you to restart Eclipse. This is a good idea, so select "Yes".

Figure 32. Restarting the workbench

Restarting the workbench

Once Eclipse has restarted you now need to configure it for your computer.

Hello, World! in older versions of CDT

Once you are in Eclipse, you are given an empty workspace. You now have to start a new project. To do so, select "File" / "New" / "Project...". Expand the section "C++" and select "Managed Make C++ Project", then click "Next >".

Figure 33. New Project screen

New Project screen

On the next screen, you have to give your project a name. In this case, it will be "HelloWorld", however, you may use any name you like. Leave the "Use default" in "Project Contents" checked.

Figure 34. New Project Name

New Project Name

The next two settings about "Project Type" and additional settings are usually OK, so we'll just leave them:

Figure 35. New Project Platforms

New Project Platforms

Figure 36. New Project Settings

New Project Settings

Eclipse will now generate a few things, and then ask you if you want to switch to the C/C++ Perspective. This is a good idea, so say yes.

Figure 37. Perspective Switch

Perspective Switch

Great. You have a project now. However, it currently does not have any files. So select "File" / "New" / "C Source File". It will then ask you for the name of the file, type in something like "main.cpp".

Figure 38. Create a new Source File

Create a new Source File

You will immediately get an editor window for your file. Eclipse will also auto-build your project every time you save. So type in something like this and hit save, and it should compile automatically:

Figure 39. Example Hello World application

Example Hello World application

Now here comes the tricky part: On the left pane, select "C/C++ Projects", expand "Binaries" and you should see and executable (HelloWorld.exe). Now right-click that executable, and select "Run" / "Run Local C/C++ Application". If everything goes well your output will be in the bottom right window in the "Console" tab and it should say "Hello, World".

Figure 40. Running the example Hello World application

Running the example Hello World application

Congratulations! You have successfully installed a compiler, a build system and an IDE. You have successfully created, edited, compiled and run a project. You should now be able to start your own projects!

Eclipse 3.1 with CDT 3.0

Downloading Eclipse 3.1

Now we are finally ready to install Eclipse. Go to the Eclipse website and look for "Downloads". It will automatically try to figure out your OS and give you an option like "Download now: Eclipse Platform SDK 3.1, Windows.". Do it. You will receive a .ZIP file. Use either FilZip or your favorite ZIP Program (Windows XP and Mac OS X have .ZIP support build in) to unpack the file. Move the unpacked folder to any location, for example C:\Program Files\eclipse. You can now start Eclipse by double-clicking it.

Figure 41. Eclipse installed into C:\Program Files\eclipse

Eclipse installed into C:\Program Files\eclipse

First Run of Eclipse

However you installed eclipse, you should now be able to run it. Double-click the icon or start the appropriate script in UNIX and Eclipse's splash-screen will appear:

Figure 42. Eclipse splash screen

Eclipse splash screen

Immediately after that Eclipse will ask you for your workspace location. It defaults to: C:\Program Files\eclipse\workspace which is actually very bad. Depending on where you want to use Eclipse, please set your workspace to the appropriate folder. If you are in a computer lab, check their policy on personal home folders. If you are on your own computer, a place within your personal settings is usually best:

Figure 43. Eclipse asking for workspace

Eclipse asking for workspace

If you always want to use the same workspace, you may select the Use this as the default... and you'll never have to worry about workspaces again. This is usually a good idea once you've used Eclipse for a while. Finally Eclipse starts up with the welcome screen:

Figure 44. Eclipse welcome screen

Eclipse welcome screen

And if you select the "Go to the workbench" in the top right corner, then you are right in Eclipse and you can start developing in Java. However, since we want to develop in C++ just continue with the next section.

Installing the CDT

Eclipse by default comes with support for programming Java, the support for C/C++ (the C Development Toolkit) has to be installed as an update.

In the "Help" menu select "Software Updates" and the "Find and Install...". You should get something like:

Figure 45. Find and Install software updates

Find and Install software updates

Select "Search for new features to install", and then "Next >". You should get:

Figure 46. Select update sites

Select update sites

Leave "Ignore features not applicable to this environment" checked and de-select all update sites (you will probably have less in there than I do). Select "New Remote Site" and then enter the following information:

Note: What name you enter does not matter. Here is the URL for cut-n-paste: http://download.eclipse.org/tools/cdt/releases/eclipse3.1

Figure 47. Add new update site

Add new update site

Hit "OK". Now select "Eclipse CDT" and then "Next >". It should connect to the Eclipse CDT update site and look for the newest version. Then it displays a window like this one:

Figure 48. Select CDT to install

Select CDT to install

Select the latest version of the "Eclipse C/C++ Development Tools". (3.0.1 at the time of this writing) Do not select any other features. Hit "Next >".

In the next window, you will have to "accept" the license, and then select "Next >".

It will again show you an overview, which you can just accept and select "Finish".

It will warn you that the Eclipse CDT is an "unsigned feature". But you can just ignore that and select "Install All".

Figure 49. Unsigned JAR

Unsigned JAR

Downloading and installing will take a while. Once its done it will ask you to restart Eclipse. This is a good idea, so select "Yes".

Figure 50. Restarting the workbench

Restarting the workbench

Once Eclipse has restarted you now need to configure it for your computer.

Eclipse 3.1 with CDT 3.0.0 (and 3.0.1) has a bug on windows! If you are on windows, please close eclipse, and delete the file spawner.dll in eclise\plugins\org.eclipse.cdt.core.win32_3.0.0\os\win32\x86. This bug appears every time you try and run short programs (they will not show any output). More information is available in Eclipse Bug 102043. This bug is fixed in CDT 3.0.2.

MinGW 4.x

MinGW 4.x comes with a new installer that asks much more questions than the old one. The current (Aug 05) version is MinGW 4.1.1.

Please note: The MinGW 4.x installer downloads parts of the MinGW suite during the install! You must have an internet connection during the install. If this is not an option for you, download the last version (3.1)

Figure 51. MinGW 4.1 install

MinGW 4.1 install

Most installation options are pretty straight forward. You will have to accept the license agreement:

Figure 52. MinGW licencse

MinGW licencse

It will ask you for a download mirror. Of course, you should pick one close to your country. If you are installing from home in the us, use a commercial mirror, if you are installing from a university connection, chose a university mirror.

Figure 53. Mirror Selection

Mirror Selection

When installing MinGW, it is advisable to use the default directory C:\MinGW. Do not use a path that contains spaces, this will give you problems later on.

Figure 54. MinGW installation directory

MinGW installation directory

If all you need MinGW for is compiling your programs from within Eclipse, the Compact install should be enough:

Figure 55. MinGW installation components

MinGW installation components

Next, it will ask you for additional tasks to perform. Select all of them:

Figure 56. Additional Tasks

Additional Tasks

MinGW will download and install your selected components. After a little while your installation is done. You will now need to install MSYS.

MinGW 3.1

At the time of this writing this was "Download MinGW-3.1.0-1.exe", but the version number may be higher now. Once downloaded, start the program. It should look similar to this:

Figure 57. MinGW 3.1 install

MinGW 3.1 install

If you accept all the default options MinGW should install just fine.

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

Home

HowTo