From "C/C++ Development with the Eclipse Platform," first published by IBM developerWorks at http://www.ibm.com/developerWorks. Reprinted with permission.
Figure 1: A C/C++ project in Eclipse
CDT is an open source project (licensed under the Common Public License) that is working towards a fully functional C/C++ Integrated Development Environment (IDE) for the Eclipse Platform. CDT is implemented purely in Java as a set of plug-ins for the Eclipse SDK Platform. Although the project focus is on Linux, CDT works in all environments where GNU developer tools are available, including Win32 (Win 95/98/Me/NT/2000/XP), QNX Neutrino, and Solaris.
Before you download and install the CDT, you first need to ensure that you have the GNU C compiler (GCC) and all the accompanying tools (make, binutils, GDB). If you're running Linux, simply install the development packages using the package manager appropriate for your distribution. On the Windows platform, you'll need to install the Cygwin toolkit (<http://www.redhat.com/software/cygwin/>). Cygwin is a UNIX-like environment for Windows that includes a GCC port along with all necessary development tools, including automake and the GNU Debugger (GDB). The alternate solution for Cygwin is Minimalist GNU for Windows (MinGW) (<http://www.mingw.org/>). MinGW is a better choice if you want to create Windows applications that are POSIX compatible.
To install CDT, you must have the appropriate Java SDK/JRE and Eclipse Platform SDK. CDT is available as either stable releases or nightly builds. Nightly builds have not been fully tested, but they offer more features and correct current bugs. Before installation, check if the previous version of the CDT exists on your disk and, if so, make sure to completely remove it. Because there are no uninstallers available for the CDT, you will need to do this manually. To check to see if a previous version exists, go to the directory where the CDT plug-ins reside: eclipse/plugins. Next, remove all directories starting with the org.eclipse.cdt name. The last thing you will need to do is remove the CDT metadata directories or.eclipse.cdt.* from workspace/.metadata/.plugins and features. The next step is to download the CDT binaries (see the official CDT website: <www.eclipse.org/cdt>). Take care to download the correct CDT for your operating system. Next, uncompress the archives into a temporary directory and move all plug-in directory content from there to the Eclipse plugins subdirectory. You will also need to move the features directory content to the Eclipse features subdirectory. Now restart Eclipse. After Eclipse starts again, the update manager will tell you that it has found changes and will ask you to confirm them. You'll now be able to see that two new projects are available: C and C++.
CDT offers an easy way to import existing source code. Go to the main menu bar and select File => Import => File System. Click Next and open the source directory and select the directories from which you would like to add files. Click Select All to select all resources in the directory, and then go through and deselect the ones that you do not want to add. Specify the Workbench project or folder that will be the import destination. You can also import folders and files by copying and pasting them, or by dragging them from the file system and dropping them in the Navigator view.
CDT also extends the standard Eclipse Debug View with functions for debugging C/C++ code. The Debug View allows you to manage the debugging or running of a program in the Workbench. To start debugging the current project, simply switch to the Debug View and you will be able to set (and change at anytime during execution) breakpoints/watchpoints in the code, trace variables, and registers.