Installing the Eclipse CDT, Part 2

For the programming in this course, we will use the Eclipse CDT. In order to follow these steps, you need to first install Eclipse. You can go to https://www.eclipse.org/downloads/ to download the Eclipse software, which then prepares you for write Java code. However, we want to write code in C++ instead of Java, so we have to take a few additional steps that are different depending on your operating system. Those steps are described in this article.

Eclipse is a "Java IDE", but it is also so much more. With the proper plug-ins, one can use Eclipse to work with PHP, Ruby, and Groovy, C, and C++. In this article, you will get started with the Eclipse C/C++ Development Toolkit (CDT).

Before we start, you need to install the following:

  • Eclipse
    • We're using the CDT, which is a plug-in to Eclipse, so of course you need Eclipse.
  • Java Runtime Environment
    • Okay, I know you want to build C++ code, but we're using Eclipse. Eclipse is a Java application itself, so it needs a Java Runtime Environment (JRE). Eclipse V3.2 requires a JRE of V1.4 or higher. If you want to also use Eclipse for Java development, you'll need a Java Development Kit (JDK).
  • Eclipse C/C++ Development Toolkit (CDT)
    • Since we are using C/C++, we need to install the CDT. See instructions below.
  • Cygwin
    • If you're using Microsoft Windows, you will find Cygwin – which provides a Linux-like environment on Windows – helpful.

 

The Eclipse CDT

The Eclipse CDT is an Eclipse plug-in that transforms Eclipse into a powerful C/C++ IDE. It was designed to bring many of the great features Eclipse enjoyed by Java developers to C/C++ developers, such as project management, integrated debugging, class wizards, automated builds, syntax coloring, and code completion. When Eclipse is used as a Java IDE, it leverages and integrates with the JDK. Similarly, the CDT leverages and integrates with standard C/C++ tools, such as g++, make, and GDB. This has lead to it becoming very popular on Linux, where those tools are readily available and used for most C++ development. The CDT can be set up on Windows to use the same tools. There is also an ongoing effort to get the CDT to work with Microsoft's C++ tools to make it even more attractive to Windows C++ developers.

 

Installing the CDT

We start by assuming you installed Eclipse and can run it. If not, consult Eclipse's Web site for getting up and running. Let's install the CDT. The CDT is an Eclipse plug-in, so it uses Eclipse's Software Updates feature. Select Help > Software Updates > Find and Install.

Figure 1. Eclipse Software Updates


Figure 2. Search for new features


If you're using a newer version of Eclipse, the Callisto or Europa discovery sites should be included. Simply select it and click Finish.

Figure 3. Callisto Discovery Site


Eclipse might ask you to choose from a list of mirror sites for the Callisto Discovery Site. Pick whatever one seems closest to you. You should see a list of plug-ins from the Callisto Discovery Site. You'll want to select C and C++ Development and click Next.

Figure 4. Available Callisto plug-ins

You'll be asked to accept the license for the CDT. Once you've done that, you can click Next. You'll see a summary of what's going to be downloaded and installed. Simply click Finish.

Figure 5. Download and installation summary

Eclipse's Update Manager will then download the CDT plug-in from the mirror site you selected earlier. The CDT is about 11 MB total, so this could take a few minutes, depending on your Internet connection speed. Once everything is downloaded, you'll be asked to confirm that you want to install the new features. Click Install All.

Figure 6. Confirm installation

After you finish installing CDT, you'll be asked to restart Eclipse. Go ahead and do that. Once Eclipse restarts, the CDT will be ready to go.

 

Windows Configuration

If you're running Eclipse on Linux or Mac OS X, you're ready to start using the CDT to develop a C++ application. If you're on Windows, there might be a few more steps. As mentioned, CDT relies on the standard GNU C++ development tools: g++, make, and GDB. These are usually included on Linux or Mac OS X. They're usually not included with Windows. But don't worry. These tools can be easily installed on Windows. Perhaps the easiest way is to install Cygwin. Cygwin provides Linux-like environment on Windows. When installing Cygwin, you'll be asked to pick the packages you want to install. Make sure to go into the development section and select gcc: g++, make, and GDB. This will cause their prerequisites to be installed, too.

Once you're done installing Cygwin, you'll need to add g++, make, and GDB to your path. The easiest way to do this is to add Cygwin's bin directory to your path, since that's where g++, make, and GDB can be found. Once that's done, restart Eclipse.


Source: Tonya Pierce and Saylor Academy
Creative Commons License This work is licensed under a Creative Commons Attribution 4.0 License.

Last modified: Tuesday, June 8, 2021, 1:38 PM