Eclipse Locally & Vim Remotely

Overview

If you don't hate IDEs, then you owe yourself a look at Eclipse. I won't get involved in the editor wars --if you don't know, don't ask. But I think Eclipse is, among other things, a feature-rich C++ platform offering features like incremental compilation, continious build, easy-to-use debugger and so on.

I've decided to use it as my local development environment next to Vim & Make that I'll be using while working on the server remotely.

This guide is split into two parts:

  • Part I: describes the installation process; and

  • Part II: briefly covers usage.

Happy Hacking!

Download & Install

Eclipse Downloads are available at: http://www.eclipse.org/downloads/

It would be interesting to download the Eclipse Modeling Tools distribution, which already includes the plugins we might need for experimenting with the UML editor.

Select your operating system and platform to proceed with the download.


 Screenshot: Eclipse Modeling Tools distribution

Install Eclipse by extracting the archive you just downloaded. GNU/Linux users can install it under /opt.

    $ cd /opt
    $ sudo tar zxvf eclipse-modeling-...-linux-gtk.tar.gz
   

Try to create a shortcut depending on your graphical environment for easier launch of Eclipse in the future.

Once you launch Eclipse, you'll be prompted to choose a workspace. This is where your project files are stored. Something like ~/ws/eclipse would be appropriate.

By installing new plugins we can adapt Eclipse to include new functionalities we need. Here we're going to add the required plugins for setting up a C/C++ IDE.

Installing CDT: the Eclipse C/C++ Subproject

Go to: Help > Software


 Screenshot: Where to install new plugins

When the wisard shows up, go to Install Software tab and then click on Add Site.... Enter the following URL in the input field.

        

http://download.eclipse.org/tools/cdt/releases/ganymede
       

 Screenshot: Add CDT Repository

You have just added a new repository, which Eclipse can use to retrieve new plugins and their future updates. Now, check the button beside the newly added repository and click on Install....


 Screenshot: Select and Install CDT Components

Proceed to install the selected plugins by following the steps suggested by the wisard and then finish the installation.

Usage

Start a new C++ project by clicking on File > New > C++ Project


 Screenshot: Start a New C++ Project

When the wisard appears, make sure that you select the right environment.


 Screenshot: New C++ Project Wisard

Note

In case you're using a version control system, you should first check out your source code and while the focus is on the project in the file browser, click on File > New > Convert to a C/C++ Make Project.

Once the project is created, you should add your source files to the project. That is, *.h files, *.C, Makefile, etc.

Build Your Project

CDT perfectly understands Makefiles and you should be able to build your project without any adaptations as the default targets are called. You could however right-click on your project and then on Properties to check the build settings of your project.


 Screenshot: C++ Project Build Settings

Run Your Project

In order to run an executable that has been generated by the compiler, right-click on the executable and then click on Run As followed by Run Configurations....


 Screenshot: C++ Project Run Configuration

Now, right-click on C/C++ Local Application and the on New.


 Screenshot: C++ Project New Run Configuration
Your run settings might look like the following screenshot.

 Screenshot: C++ Project Run Settings

Debug Your Project

Eclipse provides an excellent environment for debugging. It uses the magnificant GDB but the power is due to the fact that it provides the developer with visual control over the code and the evolution of variables.

If the you're able to run your project, you could start debugging as easily as clicking on the Debug button.


 Screenshot: C++ Projet Debugger