Setting up Eclipse

Java

Eclipse was originally written for the Java platform. It still requires a Java Runtime Environment (JRE) or a Java Development Kit (JDK), version 1.5 or greater. You will most probably already have Java installed (it comes included in Mac OS X). However, if you don't have Java installed, and you are on Windows or Linux, you can download a JRE from Sun's Java website or from java.com. At the time of this writing the latest version was Java Runtime Environment (JRE) 6 update 14. Look for the section called "Java SE Runtime Environment (JRE)" and select "JRE 6 Update 14" (or similar). You will not need NetBeans, JDK, or EE, they are just bigger downloads with more programs. You may need the JDK if you want to do Java development.

To find out if you have Java installed, and which version it is, you can open a command prompt / shell and type in:

java -version

Downloading Eclipse

Eclipse is a modular software, but ever summer there are bundled released. The link is:

I recommend the complete "Eclipse IDE for C/C++ Developers" bundle, which already contains the CDT. If you download a different bundle, you will probably have to install the CDT manually, as described in the section called “Installing the CDT”.

The file is about 79 MB in size, so it will take a while to download. You will end up with a .ZIP file. Use either FilZip or your favorite ZIP Program (Windows XP/Vista/7 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 12. 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 13. Eclipse splash screen

Eclipse splash screen

Immediately after that Eclipse will ask you for your workspace location. It defaults to a place within your personal settings. It is a good idea to use the default workspace, you may want to note where it is located.

Figure 14. 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 15. 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. However, since we downloaded the runtime only, there are additional tools needed to start programming. We want to develop in C++, so we will just continue with the next section.

Installing the CDT

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!

Note

This section described the current (3.5) version of Eclipse. For the previous version (3.4) Please see the section called “Installing the CDT”).

In the "Help" menu select "Install New Software..."

Figure 16. Select Install New Software... from the help menu

Select Install New Software... from the help 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/galigeo. If CDT is not available,, add it (using the "Add..." button), adding http://download.eclipse.org/tools/cdt/releases/galileo (the address may be different in future versions of Eclipse, this is for 3.5!)

Figure 17. Available Software Update page with Add... opened

Available Software Update page with Add... opened

When you have found the CDT site, it will give you two entries: CDT Main Features and CDT Optional Features. Expand both, 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 18. Select CDT from the Update Site

Select CDT from the Update Site

The select "Next..."

You will have to confirm the selection with "Next".

And accept the license agreement 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 19. Restarting the workbench

Restarting the workbench

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

Configuring the CDT

Fortunately, this is very easy. If your path is set correctly, there should be absolutely nothing you need to configure. This is especially true if you followed these instructions for Windows systems.

On some Unix systems you might have to change your "make" program to "gmake". You will find the setting in Window / Preferences. Then expand "C / C++", then "Make" and select "New Make Projects". At build command, de-select "use default" and at "Build command" enter "gmake".

Hello, World!

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 "C++ Project", then click "Next >".

Figure 20. 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. Also, you have to select a toolchain, if you followed my instructions you are using the GNU Toolchain, and it should automatically give you the right option. Click "Next".

Figure 21. New Project Name

New Project Name

The next screen contains some Basic settings. Fill in what you like:

Figure 22. Basic Settings

Basic Settings

In the last setting you can chose output formats, it is always good to have a release and a debug configuration. Click "Finish".

Figure 23. New Project Platforms

New Project Platforms

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 24. Perspective Switch

Perspective Switch

Great. You have a project now, and it does contain some sample code! You will immediately get an editor window for your project. Eclipse will also auto-build your project every time you save.

Figure 25. 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 26. 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!

Home

HowTo