Open source software security

Remote C Development Using Eclipse

31 August 2011
One of the major challenges to most beginning C programmers is the lack of a good, open source IDE. C programming is daunting enough for most people, and having to utilized Unix editors like Vi or Emacs doesn't make C any more approachable. GNU/Linux is an ideal environment for learning C because of the easy availability of the powerful GCC and GDB tools. Unfortunately many beginning programmers work from a Windows environment, and their choices for C development seem limited to Microsoft Visual C++. Remote C development using Eclipse

One of the major challenges to most beginning C programmers is the lack of a good, open source IDE. C programming is daunting enough for most people, and having to utilized Unix editors like Vi or Emacs doesn't make C any more approachable. GNU/Linux is an ideal environment for learning C because of the easy availability of the powerful GCC and GDB tools. Unfortunately many beginning programmers work from a Windows environment, and their choices for C development seem limited to Microsoft Visual C++.

Fortunately for these aspiring programmers there are newly available options. Developers can also opt for utilizing MinGW, a GCC port for windows. Virtualization allows these new programmers to operate a VMWare or VirtualBox virtual machine from their own desktop. Developers might also be able to set up their own Linux environment on spare hardware. This article addresses all three scenarios, but is most pertinent to the last two.

Eclipse is a well known development environment amongst Java developers. Thankfully for those who have become familiar with Eclipse there are extensions that allow development in other languages. Eclipse IDE can be used for Java, PHP, C/C++ development and more. Eclipse is normally configure for developing Java, but with a few tweaks it can easily be used as a robust, and friendly, C development environment.

If you don't have a C compiler handy on your Windows machine, or if you want to focus on C development under Linux a new hurdle presents itself to users with a Windows based workstation. There are many ways to get a running Linux installation, either real or virtual, installed for development, but then the challenge becomes remote access to these systems for development.

SSH is an excellent, secure (encrypted), protocol for accessing remote Linux environments. Utilizing the RSE (Remote System Explorer) plugin (part of the Target Management Project http://www.eclipse.org/dsdp/tm/) for Eclipse we can gain remote access to a filesystem via SSH. Once remote access and the proper C extensions are installed in Eclipse it is easy to proceed with C development from the comfort of your Windows desktop.

The first step to this setup is to download and install Eclipse. The latest versions of Eclipse can be downloaded from http://www.eclipse.org/. If you download the Eclipse for C/C++ developers you can skip some of the steps below. I'm assuming you've downloaded and installed the Eclipse version for Java developers.

The first thing to do is to start up the Eclipse IDE. Once Eclipse is started we're going to add some new extensions. This will involve adding some extension sources as well as choosing some extensions from default sources. To start select Help->Software Updates... Next click the 'Available Software' tab.

Eclipse available sources

Now click the 'Add Site...' button and in the resultant window enter the URL http://download.eclipse.org/dsdp/tm/updates/ in the 'Location' text area. This is the location for the Target Management site which contains RSE. Once you have this site added it will show up in the 'Available Software' tab.

In the 'Available Software' tab expand the 'http://download.eclipse.org/dsdp/tm/updates/' site by clicking the plus icon next to the name. Also click the plus icon next to the name of the Eclipse IDE you have installed (in my case this is 'Ganymede). Finally click the box next to 'C/C++ Development' and 'RSE runtime' in the Eclipse IDE name and TM updates site respectively. Finally click the 'Install' button to install RSE and the C/C++ development extensions. Once you click Install you'll be prompted to confirm your selections. You should see all your chosen extensions listed, which should look like this:

Confirm Eclipse installations

Once the updates are installed you'll be prompted to restart your workspace. Do so at this point.

Prompt to restart Eclipse

When Eclipse restarts you'll notice that you now have options for C/C++ Development.

Eclipse with C/C++ development options

Next we'll try to access a remote system and set up a C project to work on. For this example we'll assume we're running a Linux environment at 192.168.42.128. To start you need to open a new perspective. To do this go to Window->Open Perspective->Other->Remote System Explorer. Next select 'Remote System Explorer' and then the 'OK' button.

Opening a new remote system explorer perspective in Eclipse

This will open up a completely new workspace in Eclipse. You'll notice that there is a 'Remote Systems' tab in the left hand sidebar pane. We'll need to add a new remote connection to this sidebar in order to connect to a remote system. To do this right click in the 'Remote Systems' pane, select New->Connection.

Establishing a new remote connection in Eclipse

This will open a new window where we can specify the connection settings. RSE supports several connections, including SSH and FTP. For this example, we want to select 'SSH Only'.

Selecting an SSH connection in RSE with Eclipse

Once we've selected an SSH connection we have to provide the appropriate connection details. The connection name and description are arbitrary, but the host name is important. Be sure the host name corresponds to your remote Linux environment.

Setting up the remote SSH connection in Eclipse

Once the connection is set up you'll see your new remote system in the left sidebar of eclipse. Clicking on this connection, then on the destination (under 'Sftp Files') will prompt you to enter your username and password. You can select to save this password if you like. Fill in the proper credentials and click the 'OK' button.

Entering connection credentials for remote SSH site in Eclipse

After this is complete you should see the directory listing of your remote site.

Connected to a remote site

From this point you can create and edit C source code. Eclipse provides handy syntax highlighting for your C project. Once you're up and running you should find that Eclipse presents many advantages over using a simple text editor. Using a full blown IDE helps to streamline development, debugging, and deployment of your C applications. There are other Eclipse tools that can help you compile and debug your code, but these are beyond the scope of this article. With remote C development you should have enough at your fingertips to get started with C programming on Linux from the comfort of your Windows environment with a familiar IDE.