Difference between revisions of "CDT/User/FAQ"

From Eclipsepedia

< CDT
Jump to: navigation, search
(Working on the CDT)
m (Added the words "CLI" and "command line interface" to improve searchability)
Line 396: Line 396:
  
 
== Debugging C/C++ Projects ==
 
== Debugging C/C++ Projects ==
==== Since the debugger is gdb, can I simply access the gdb console? ====
+
==== Since the debugger is gdb, can I simply access the gdb command line interface (CLI)? ====
  
Yes, partially. To access the console, select the gdb process node in the Debug view.  The gdb console will then be available in the Console view.  Though no prompt is visible, one can enter commands at that point. Doing so may desynchronize the IDE with gdb, so be careful when driving the debugger using this interface.
+
Yes, partially. To access the gdb CLI, select the gdb process node in the Debug view.  The gdb command line will then be available in the Console view.  Though no prompt is visible, you can enter commands at the bottom line of the Console view. Doing so may desynchronize the IDE and gdb, so be careful when driving the debugger using this interface.
  
 
==== I'm using cygwin and when launching the debugger, it complains that it can't find the source file ====
 
==== I'm using cygwin and when launching the debugger, it complains that it can't find the source file ====

Revision as of 16:18, 31 January 2008

Contents

Introduction

How do I contribute to this FAQ?

Simply edit this page. You will need to log in using your bugzilla username and password to gain access. If you don't have a Bugzilla account, you can create a new one.

Is it really that easy?

Yes!

General

What is the CDT?

The CDT (C/C++ Development Tools) Project is working towards providing a fully functional C and C++ Integrated Development Environment (IDE) for the Eclipse platform.

There are a number of groups contributing to the CDT; We strongly encourage interested parties to extend our work, thereby making the Eclipse CDT project a richer set of freely available resources. We are looking for contributions from the open source community in the areas of test, development, documentation, and general users who can help us ensure that the C/C++ tools work well on all the Eclipse platforms.

Our current release function includes:

  • C/C++ Editor (basic functionality, syntax highlighting, code completion etc.)
  • C/C++ Debugger (APIs & Default implementation, using GDB)
  • C/C++ Launcher (APIs & Default implementation, launches and external application)
  • Parser
  • Search Engine
  • Content Assist Provider
  • Makefile generator

Default implementations of all interfaces and extension points will be supplied for various platforms.

The CDT is fully open-source and implemented purely in java as a set of plugins to the Eclipse platform. To learn more visit the CDT Home Page.

How is the CDT licensed?

The CDT consists of software produced by the CDT team combined with third party software developed from other Open Source Projects. The software produced by the CDT team is licensed under the Common Public License. The software designed by third parties is made available under their respective licenses. Refer to the about.html file in the root directory of every CDT plugin for specific licensing information.

How is the CDT Project organized?

Visit CDT Project Structure to find out more about the organization of CDT (History, participants, and project structure).

How do I find out about future releases of the CDT?

See the CDT/planning section.

If you wish to contribute to the development of the CDT, we welcome the opportunity to work with you. The plans will be updated to reflect the commitments made by contributors to this projects. See Working on the CDT for information on how to get started.

Release Milestones (which represent planned availability dates for Stable CDT builds) are noted in the CDT Plan Documents which can be found on the CDT Overview Page. To see the currently available CDT builds, choose from either the current official release or from the nightly builds.

What is the default configuration supported by the CDT?

This is a bit of a moving target, but currently the compiler supported (from an error parsing point of view) is gcc, the debugger interface will work with gdb 5.2.1 (or higher) and the default build command is GNU "make".

Which operating systems does the CDT support?

The CDT Framework is platform independent. It will run where Eclipse will run. However, the default implementations may depend on external applications. To follow in the Eclipse spirit of open source, the default implementations rely upon freely available open source tools, such as the GNU Tools: GDB and Make. Therefore, the dependencies on GDB for debugging, or Make for building, will require that these applications are available for the platform that the user wishes to use. References to some of the known implementations for each platform will be indicated in the sections of this FAQ that include instructions for installation, project creation and building the CDT on the various platforms.

Which platforms are fully supported will ultimately depend on the needs of the community, as expressed by the participation in developing, and testing for each platform?

The core plugins are written in Java with no native code and thus may be ported to any platform supported by Eclipse. However, some default implementations may require that other software or tools, licensed under GNU, may be required.

In general there is some version of Linux and some version of windows used by the developers on the CDT. For an exact list of supported platforms see the Downloads page.

Why isn't the XXX operating system supported by CDT?

"Supported" has a particular meaning to us. It means that on that platform we have a good level of confidence that CDT works correctly and that its function is appropriate and complete. That means

  • someone has ensured that the function addresses the important use cases
  • the function is exercised by regular execution of a test plan
  • identified problems are tracked to resolution
  • there is a recipient for user feedback
  • code patches are developed as necessary to correct or extend CDT on that platform

To make this all happen a platform has an Owner - someone who accepts the responsibility to make sure those things all happen.

The Framework supports all the platforms that Eclipse does. The CDT team is responsible for ensuring that this remains true for the framework. Specific default implementations will work only on platforms where the required applications are available. The following list is derived from the initial CDT meeting in July 2002. The following companies have agreed to provide support for the associated platforms:

Platform Company
QNX Neutrino QNX Software Systems Ltd.
Linux IBM, Red Hat
Windows IBM, MontaVista with initial support from QNX

If you have a favorite platform we highly encourage you to get involved and volunteer to own a feature that does not currently have an implementation that works on your platform of choice. See #Working on the CDT for more information.

How do I ask questions?

CDT related questions that are not answered in this FAQ or the documentation should be posted to the CDT newsgroup. You will need a password. You can also use this simple web interface to browse the newsgroup. General Questions about the Eclipse SDK which includes the Eclipse Platform, JDT (Java Development Tools), or PDE (Plugin Development Environment) should be posted to the Eclipse newcomers newsgroup.

Keep in mind that these newsgroups are public, so do not include any confidential information in your questions. You should also read "How to ask questions the smart way" by Eric Raymond before participating in the newsgroups. NOTE: Please submit bugs to bugzilla, not to the newsgroups. See the How do I report a bug or request a feature? section of this document.

People will still come into a newsgroup asking questions that have been answered before and often will not provide any information about what versions they have installed, and what the problem is. You will be much more likely to get help if you provide enough information to reproduce the problem. The section on how to report a bug gives a list of some information which could be useful.

How do I report a bug or request a feature?

The CDT Project (like the Eclipse Project) uses bugzilla as its bug and feature tracking system. Entering a bug/feature report is as simple as filling in a web form on the eclipse bugzilla page. The first time you enter a bug you will need to create a new bugzilla account for yourself by providing an email address and choosing a password.

Before entering a bug report, you should search bugzilla to see if someone else has already entered a bug report similar to yours. If you find a bug report that outlines the problem you are seeing, you can simply annotate it with your comments to let the developers know that you have also hit the bug. Also you can add yourself to the CC list of the bug so that you will notified when the status of the bug changes or someone adds comments.

Once you have searched bugzilla and not found anything, you can go ahead and enter a new bug report. Please read the bug writing guidelines located on the eclipse bug reporting page.

To make your bug report more helpful include the following in your bug reports:

Environmental settings:

1. The build level of Eclipse that you are using. For example, "Eclipse 3.0M6"
2. The build level of CDT that you are using. For example, "CDT build 2.0.0.0026"
3. Your computer's specifications (OS version + patch level, memory, other pertinent info)
4. The contents of your .log file (or lack thereof). This is especially important if you get a dialog that reports an internal error. See What is this .log file I hear so much about? for information on finding your .log file.
5. The Java runtime or development kit you are using to run eclipse (use java -version or java -fullversion)

Problem Description:

1. A description of what you were doing,
2. A description of what behavior that you observed, and
3. An explanation of how the observed behavior differs from the expected behavior

Where is this .log file that I hear so much about?

The .log file is located in the workspace/.metadata directory.

The .log file is used by the Eclipse Platform to log runtime errors. It is useful to include it in bug reports because it contains stack traces that occur in plug-ins. When you report a bug, make sure to include your .log file!

Download and Installation

Are there complete HowTos for setting up the CDT?

Yes, please see

Which CDT build should I download?

The latest stable release version is available from the CDT downloads page.

I can't find the CDT download for the XXX operating system?

The CDT is supported on the platforms specified on the download page. The downloads are structured and named to indicate, which OS and windowing system it runs on. If you do not see your OS/windowing system combination please contact us. We are always looking for volunteers to test and support platforms.

Much of the CDT default functionality uses applications that are available on most operating systems. The CDT leverages some default system tools such as gdb (debugging), make (building). These tools are available for many platforms and if they exist on your system, there is a good chance that the default functionality will work. See Compilers and other 3rd party tools for more information

The caveat is that the operation of the CDT on some operating systems has not been fully tested and we cannot commit time to fixing platform specific problems found on these platforms. However, code submissions from developers wanting to improve the CDT will always be gratefully accepted. See Working ON the CDT for more information.

How do I uninstall CDT?

We do not currently ship an uninstaller. You can uninstall the CDT manually:

1. Shutdown the eclipse shell that is running CDT
2. Remove the CDT plugins
  • Navigate to the directory where the CDT plugins are installed (typically eclipse/plugins)
  • Remove the following plugins:
  • org.eclipse.cdt.*
3. Remove the CDT metadata
  • Navigate to the workspace/.metadata/.plugins directory
  • Remove the following directories (if they exist):
  • org.eclipse.cdt.*
4. Restart Eclipse

How do I convince Eclipse to "re-read" the configuration files?

Delete the following:

  • /configuration/org.eclipse.osgi/manifests
  • /configuration/org.eclipse.osgi/.bundledata
  • /configuration/org.eclipse.osgi/.state

and restart eclipse.


Which bugs were fixed in CDT 3.1.2 release?

To find which bugs were fixed in this release, run this bugzilla query: List bugs fixed for CDT 3.1.2 release

C/C++ Project Creation

Creating a simple Managed C++ Project -- "Hello World on a Windows Platform"

(Note: See these two FAQ entries to decide whether to use a Standard Make project or use a Managed Make project.)

This section will use an example to create the familiar "Hello World!" C++ program. First, ensure that you have the CDT installed within Eclipse, as described above. Open a C/C++ Perspective and complete the following steps:

1. Click "Project" from the menubar and ensure there is no checkmark beside "Build Automatically" -- if there is one, click "Build Automatically" to deselect it. ("Build Automatically" disables the build menus and buttons; you may want to turn it on later to avoid having to rebuild manually when modifying your projects.)
2. In the "C/C++ Projects" View, right click and select "New Project ..."
3. Expand "C++", then select "Managed Make C++ Project"
4. Enter a name for the new project and select "Finish". Note: you can determine the build Settings from this dialog, but we will do so later, in the build section.
5. In the "C/C++ Projects" view, right click and select "New" > "File". Name your file "hello.cpp" and click "Finish".
6. Copy or type the following text into the "hello.cpp" file:
     #include <stdio.h>
     int main()
     {
         printf("hello, world\n");
     } 
                   
7. Save the file.

There are several ways to initiate builds and to run the executable from the menu, toolbars, keyboard, and other objects. Descriptions of them all can be found in the Eclipse documentation. These work from the project object in the "C/C++ Projects" panel:

8. Right click the project panel and select "Build Project". A popup and the Console tab will show the build status. If there are errors they will show up in the "Problems " panel.
9. Right click the project panel and select "Run As" > "Run Local C/C++ Application". The Console tab will show your program's output. The "Debug" panel will show the exit status, or the state of the program if it failed to terminate correctly.

Creating a simple Standard C++ Project -- "Hello World on a Windows Platform"

(Note: See these two FAQ entries to decide whether to use a Standard Make project or use a Managed Make project.)

This section will use an example to create the familiar "Hello World!" C++ program. First, ensure that you have the CDT installed within Eclipse, as described above. Open a C/C++ Perspective and complete the following steps:

1. In the C/C++ Projects View right click and select "New Project ..."
2. Select "C++" in the left pane and the select "Standard Make C++ Project"
3. Enter a name for the new project and select Finish. Note: you can determine the "Build Settings" from this dialog, but we will do so later, in the build section.
4. In the C/C++ Projects View right click and select "New" > "Simple" > "File". Name your file hello.cpp
5. Repeat the previous step and name the second new file "makefile".
6. Copy the following text into the "hello.cpp" file:
     #include <stdio.h>
     int main()
     {
         printf("Hello World\n");
                         
         //block until user types something
         fgetc(stdin);
         return 0;
     } 
Now, save the file.
7. Copy the following text into the "makefile" file:
Remember that makefile requires that indented lines use a <tab> character and not spaces
     hello.exe : hello.o
     	g++ -o hello.exe hello.o
     hello.o : hello.cpp
     	g++ -c hello.cpp
     	
     all : hello.exe
     clean :
     	-rm hello.exe hello.o
              
Now, save the file.

How do I create a new project using a directory full of existing source?

If the source is accessible to the user from their desktop using the command line then it is possible to simply make the root directories containing that source as Eclipse projects. This is accomplished by invoking the New Project Wizard, selecting C or C++ and then Standard Make Project as the project type. On the next page, enter a name for the project, the deselect the "Use Default Location" checkbox. This will let you Browse to the root folder of the source tree. After setting other information and clicking on Finish, the project will be created in the root of the source folder you have selected.

The resource for the project are maintained in the remote location specified, not in the workspace folder for eclipse. Meta data for the project, such as the index for the project and the "link" to the project, is stored in the metadata directory in the workspace folder.

How do I create a new project using CVS?

If the existing source tree is managed in CVS, it is possible to use the CVS Repository perspective to "Checkout As Project" any folder in the repository. The first time this is done, a Simple Project is created for the folder. To access the features of the CDT for this project, the project must be converted to a C or C++ project using the "Convert to a C or C++ Project" project type in the New Wizard.

This does a CVS checkout of the project into the project's location (usually in the workspace).

How do I Import existing code into an existing project?

Another approach would be to create the C/C++ Project and then do an "Import"->"File System". This will make a copy of the files from the selected location into the selected folder in the project. With the copy, this approach is more wasteful and detaches the source from any control mechanism that existed in the original file location (e.g. a ClearCase view)

Adding C/C++ External Libraries

How do I add an external library to my C++ project?

Go to Your Project's Properties by right clicking on project's name and selecting properties. Click on "C/C++ Build". Under Tool Settings Tab, click on Directories. Click on The Add Button and Select FileSystem. Select the folder with C/C++ libraries. Apply and then Ok. The new library is included.

The option commented before didn't work when I tried it. I solve it including the external library I want to add (libwsock32.a in my case) in Project->Properties->Tool Settings Tab->C++ Linker->Miscellaneous.

14:26, 18 December 2007 (EST): Neither of these worked for me under Linux. I had to open up the project's properties and go to "C/C++ Build" -> "Settings" and then hit the "Libraries" item under "GCC C++ Linker" heading in the list on the right. Then, I entered the libraries as I would in the command line ("pthread" for libpthread, etc...). (Dustin Oprea)

Editing C/C++ Projects

I'd like to use the code assist functionality, but it doesn't seem to work for me. I don't get anything showing up when I select CTRL+SPACE in a C/C++ source file.

Content Assist is a work in Progress. For CDT 2.0 you should be able to ask for code completion anywhere in your source file. If you fail to find a completion you expect to find, most probably this is because of a failure in parsing your source file. In this case, check that you have added the correct set of include paths to the project containing your source file.

For example, in the following code:

     int main() {
         pr
     }

You should not expect "pr" to provide "printf" as a completion unless:

  • You have an #include <stdio.h> in the file
  • the include path to stdio.h is available in the project
  • any macro's necessary to read stdio.h are set (often a missing macro will cause a system header to encounter a #error in the header file -- for example on windows using cygwin, the defining the symbol __i386__ will allow stdio.h to be understood)

As we improve and further develop the CDT, this function will get better and better.

Search is broken!

Often when search is not behaving as expected, it is due to the CDT not having enough information available to parse the source files. For example, if you include a header file, but do not tell CDT about the directory where that header file exists, then it is unlikely that CDT will understand the contents of your source file.

I am having problems with the outline view

The outline view does not respect macros and header contents. It is simply a file view. This may not be what you desire.

I am using a non gnu compiler and I get the following messages: "Error launching external scanner info generator (gcc -E -P -v -dD" and "File not indexed because it was not built ". How do I get rid of them?

In general the parser needs to know the include paths and macro definitions for each source file and the compiler built-ins before it can be parsed(the indexer is one client that will parse the files).

In CDT there is a scanner config feature that will invoke the compiler "gcc -E -P -v -dD" to ask it for the default values. This feature will also look at the output of running "make" and try to determine which includes (-I) and which defines (-D) have bee set on the command line.

Your project has been setup to use the defaults for gnu to get this info. Since you are using a non-gnu compiler, you should disable all of the discovery feature. Got to the Properties on your project and open the section "C/C++ Make project" and select the "Discovery Options" tab. Deselect the "Automate discovery of paths and symbols" and these errors will go away.

Note that you will then need to manually add the paths and symbols to the project (or you will get a lot of other parser errors). This can be done from the same dialog under "C/C++ Include paths and symbols".

How can I add another extension to CDT so that files other than c/cpp/cc/h files are recognized as source files? My compiler needs the file extension to be "xyz", and when I open xyz files there is no syntax highlighting.

There are a few places to find and set these associations. You may need to add your file extension to all of these containers to get all of the capabilities you expect:

1. Window > Preferences > General > Content Types. This tree associates a filename or filename pattern with its content type so that tools can treat it properly. Source and header files for most languages are under the Text tree.
2. Window > Preferences > Editors > File Associations. This list associates a filename or filename pattern with the program needed to edit it, if the default editor is insufficient.
3. Window > Preferences > C/C++ > File Types. This list associates a filename or filename pattern with its generic content type so that tools can treat it properly.

Building C/C++ Projects

When do I use the standard make feature

When you already have a makefile and you wish to use it.

When do I use the managed make feature

When you do not have a makefile, and do not want to write one, the managed make feature will be able to generate one for you. Note that the current CDT (1.2.1 and 2.0) generates makefiles that use GNU gcc and g++. If you are not using this compiler, (and you do not have a managed make plugin for your compiler), then you will need to use the standard make feature.

Where are the Build menus? I could not invoke building action by clicking. However, after saving action, the project would be built and an executable would be generated.

The Build Automatically flag removes the build menus. (This was proclaimed a feature and not a bug in Bugzilla Bug 71443.)

For your first C/C++ projects Build Automatically should be turned off, otherwise builds will be performed whenever a file is saved, including makefiles and header files. Doing this manually will help you figure out what is going on in Eclipse and CDT. It can also be helpful to turn it off for large projects with intricate dependencies that generate a lot of rebuild action when certain files are touched. And there are other menu items and buttons that will be enabled.

Click Projects from the menubar and ensure there is no checkmark beside Build Automatically. If there is one click Build Automatically to un-check it.

You should now be able to Build and Clean a project.

In CDT 4.0 I check "Build Automatically" but my files don't get built when I save a source file.

Edit the project properties (context menu on the Project in Project Explorer, Select 'Properties' at the very bottom) Select C/C++ Build and click on the Behaviour tab. Check 'Build on resource save (Auto build)’

Building a simple C++ Project -- "Hello World" on a Windows Platform

1. Follow the instructions, on the respective web site, to install your GNU tools.
2. Create a new C++ project
3. In the C/C++ Projects View, select your new C/C++ project, right click and select "Rebuild Project"
4. You will have two additional files. "hello.o" and "hello.exe"
5. Double click on "hello.exe" or right click and select "Open With" > "Default Editor" to launch your simple program.

Can I see the raw compiler output? Where is this information placed?

The C-Build view is a console which shows all of the activity which occurs once a project's build command is executed.

I get the error 'Build error (Exec error: Launching failed)'

This usually indicates that "make" is not on your path. Open a command window and type "make". If you receive the equivalent of "command not found" then you will need to ensure that the location of the make executable is on your path. (If you have changed your build command to something else, like "mingw32-make -f makefile" then this something else needs to be on your path.)

Note that the managed build project will always use "make.exe". If make.exe does not exist it will not work.

I get "make Error 127 line 0" when trying to build

Ensure that you have the appropriate GNU tool chain (make, gcc, g++, gdb) installed and available on the path.

My Compiler errors seem to be truncated or split. What is going on?

When using GCC toolchain, you need to add to each compile/link line the following (either in Makefile, add this to CFLAGS/CXXFLAGS/LDFLAGS, or when using managed builds, add this in each configuration to the misc-sections):

-fmessage-length=0

This will disable the line breaks in the compiler and linker error messages.

What causes the message 'make (e=2): The system cannot find the file specified'?

This message usually indicates that the a tool called from inside the makefile is not found (on the path). If the error looks like the following, then "gcc" could not be found:

gcc -c hello.c
Process begin: CreateProcess((null), gcc -c hello.c, ...) failed.
make (e=2): The system cannot find the file specified.

You will need to ensure that the path to the executable "gcc" is on your path.

You might also want to check that the path delimiter of the PATH environment variable on Windows Systems is a backslash (\), but eclipse need to have the path delimited with forward slashes (/). So you might have to change the appropriate environment variable string.

How do I exclude files from being built in a managed make project? I have tried setting up individual source folder in the Project->Properties panel, but the managed make seems to always include all source file in the project, regardless of the Project Paths settings.

The ManagedBuilder does not respect the src paths when generating the makefile (as of CDT 2.0). However, there is a hack to prevent the generated makefile from building files.

To remove the file "devices/devices.c[pp]" from the build, add a file named "makefile.defs" to the project ROOT and added the following lines to it:

OBJS := $(OBJS:devices/devices.o=)

That has the effect of removing the offending (i.e. non-compiling) sources from the required objects and hence make will never attempt to build them.

Debugging C/C++ Projects

Since the debugger is gdb, can I simply access the gdb command line interface (CLI)?

Yes, partially. To access the gdb CLI, select the gdb process node in the Debug view. The gdb command line will then be available in the Console view. Though no prompt is visible, you can enter commands at the bottom line of the Console view. Doing so may desynchronize the IDE and gdb, so be careful when driving the debugger using this interface.

I'm using cygwin and when launching the debugger, it complains that it can't find the source file

You must provide a mapping from /cygdrive/c to c:\ (or whatever your drive letter is).

To do this,

  1. From the editor error page, select the "Edit Source Lookup Path..." button and select the "Add..." button
    • Or, in the eclipse IDE, go to menu Window -> Preferences -> C/C++ -> Debug-> Common Source Lookup Path -> Add.
  2. From the list of lookup containers, choose Path Mapping and OK. You get a New Mapping in the list.
  3. Select the mapping and then Edit. In the Modify the path mappings dialog, select Add, and then enter:
    • /cygdrive/c as the compilation path and
    • c:\ as the local file system path.
  4. Select OK, OK, OK to finish the dialogs.
  5. Terminate the debug session and restart; it should find your source files now.

This setting will apply to any debug sessions launched from this workspace.

You can also modify the settings in each individual launch configuration.

Other Questions

Not yet available, in the meantime see old FAQ.

Miscellaneous Troubleshooting

Under construction. In the meantime see old FAQ.

When I attempt to run my application, I get the following error

     Entry Point Not Found - The procedure entry point __getreent could not be located in the dynamic link library cygwin1.dll.

Cause: a different cigwin1.dll is picked up from your PATH first. Solution: make sure that only the cygwin1.dll that comes with your active installation of Cygwin is available in the PATH environment variable.

Compilers and other 3rd party tools

Does CDT include a compiler?

CDT does not come with a compiler, so if you do not have one you will need to install one. Follows are options available to you:

* MacOS X: Install the developer tools DVD that came with your computer or with you MacOS X DVD.
* Linux: If not already installed, it should be available on your installation CDs.
* Windows: You have a choice of compilers available:
* Cygwin: Cygwin is a Linux-like environment for Windows, includes GCC.
* MinGW: Environment that includes development toolsets
* DJGPP: DJGPP is a complete 32-bit C/C++ development system for Intel 80386 (and higher) PCs running DOS.

The web page http://www.thefreecountry.com/compilers/cpp.shtml contains a list of free C and C++ compilers for various platforms and targets.

Working on the CDT

How do I get a more recent build than is on the downloads page?

http://download.eclipse.org/tools/cdt/builds/

These plugin builds can be installed for use in the usual way via Software Updates -> Find and Install... but are packed which the corresponding PDE project files and source code.

Once installed you can import the project and source code into the PDE (Plugin Development Environment) so you can modify rebuild and test using the PDE. The PDE function to do this is accessible from File -> Import... -> Plugin Development -> Plug-ins and Fragments. Alternatively, from the Plugin Development perspective's Package Explorer you can access it via a right-click. In either case if you're new enough to eclipse to be reading and following this you almost certainly want import the CDT plugins as with-source projects (so you can change stuff) but import the eclipse plugins the depend on as binary-only projects.

The self-hosting instructions explain how to do this in the (misleadingly named) section 'Importing binary projects'. The basic recipe is:

  1. Import the cdt plugin as projects with source code...
    1. Use the default import source (its the design eclipse you're running right now and Install the CDT build package into).
    2. Select 'Select from all' and 'Projects with source folders'.
    3. Next>
    4. Select the org.eclipse.cdt.* plugins/fragments you want to play with (for first experiments you probably want all of them) and 'Add'.
    5. Finish.
  2. Import the remaining plugins as binary-only projects so the run-time eclipse you're going to start from the PDE has all the prerequisite plugins the CDT relies on.
    1. Use the default import source
    2. Select 'Select from all' and 'Binary projects'
    3. Next>
    4. Select your already imported plugins using the 'Existing Plugin' button.
    5. Swap these for all the rest using the 'Swap' button.
    6. Finish.

How do I build CDT from CVS if I want an even more recent build and I want all the pieces and parts?

The short answer:

  1. Connect to CVS repository: :pserver:anonymous@dev.eclipse.org:2401/cvsroot/tools
  2. Check out: org.eclipse.cdt-releng/all

The long answer:

  1. Switch to the CVS Perspective: Window > Open Perspective > Others ... and select "CVS Repository Exploring"
  2. Context menu in "CVS Repositories" View, New > Repository Location
  3. Location - Host: dev.eclipse.org Repository Path: /cvsroot/tools
  4. Authentication - User: anonymous (no password required)
  5. Connection - type: pserver
  6. Click 'Finish'
  7. Open up the resulting /cvsroot/tools tree.. find org.eclipse.cdt-releng/all
  8. On each of the projects under 'all', click context menu > Check Out

How do I export it so that it can be used with an external Eclipse installation?

You can either:
a) Export the CDT feature via File->Export->Plugin Development->Deployable Features. This will automatically export all the required plugins.
b) Export all the plugins etc. individually or all at once via File->Export->Plugin Development->Deployable Plugins and Fragments. However, this is more error prone and you're better off doing a).
c) Use the ANT stuff in org.eclipse.cdt.releng to build CDT the way the nightly build does.

How do I use eclipse to develop eclipse?

The self-hosting instructions explain how to use eclipse to develop eclipse.

  • If you want to work with the current version of the eclipse code, you will need to connect to the Eclipse Project CVS repository. To connect to the Eclipse Project CVS repository, open the CVS repositories view (Perspective->Show View->Other...->CVS->CVS Repositories) and create a new CVS repository location (right click->New->CVS Repository Location. Enter the following information into the "Add CVS Repository" dialog.
  • Connection type: pserver
  • User name: anonymous
  • Password: <leave empty>
  • Host name: dev.eclipse.org
  • Repository path: /cvsroot/tools

NOTE: When you are connected as anonymous you will have read rights to the repository, but you will not be able to commit any code.

How do I modify the code and build the result

Its best to work using the PDE perspective - change any file you want! The PDE perspective is basically an extension of the normal Eclipse Java development perspective so the basic mechanics are the same.

However, the source packaging may be a little erratic here and there (it certainly was in the 4.0.2 packages) and so a little hand tidying up may be necessary before things finally build cleanly.

  • If when you build you get hundreds of errors and warnings relating to the use of the assert statement the packaged projects Java Compiler source compatability settings are wrong. You'll need to tweak the corresponding project settings so that at least JDK 1.4 source compatibility is set. In early experiments I found a quick and dirty
  • Similarly, a few CDT plug-in projects imported might lack source code (in 4.0.2 some xlc and gdbjtag projects) - which can cause PDE errors. You'll need to delete these and re-import them as binary plugins.

How do I run with my changes?

After successfully building the CDT inside Eclipse, one typically wants to run an instance of Eclipse with the freshly built plugins (perhaps after making some changes to the source code). This is very easy to do in the PDE. Here are the steps:

1. Open the "Plug-in Development" perspective (you may have to go to "Others" to find it).
2. Select the menu action Run -> Run As... -> Run-time workbench.
3. You may also use the drop down on the debug icon, select Run-time workbench

How do I submit a fix for a bug?

While using the Eclipse SDK to develop your plug-in, you found a bug in CDT. You submitted a bug report, but need the fix now. You've debugged the problem, and there is a simple fix. So you figured out how to use eclipse to develop eclipse and have written a fix for the bug you found. Now you want to release the fix to the eclipse community. How do you do this?

First, create a patch. You can create a patch by using the Team patch creation facility.

1. Select the project you have patched. It must be connected to the CDT CVS repository.
2. Right click->Team->Create Patch...
3. The Create Patch wizard will prompt you for a file name. You should name your patch with the bugzilla bug report id.

Now you can attach the patch file to the bugzilla bug report, and add a post to the appropriate component developer mailing list. Be sure to include information about what your patch fixes. The committers for the component will evaluate your patch to see if it fixes the bug and is acceptable. If your patch is accepted, it will be released by the component team into the repository.

How do I distribute my changes to my customers?

Anyway that you see fit! Actually, if anybody has suggestions for this answer, please send them to the cdt-dev mailing list.

How do I generate JavaDocs?

The following steps can be used to create JavaDocs for any CDT project.

1. Check out the project (i.e. org.eclipse.cdt.debug.core) from dev.eclipse.org with cvsroot /home/tools
2. Ensure that you have JavaDoc installed and configured (go to preferences->Java->Javadoc and set the location for the javadoc command
3. Select the project in the package explorer, right-click Export, select Javadoc and follow the wizard instructions. It will generate the Javadoc html in a doc directory for that plugin

The result will be a complete JavaDoc hierarchy of all the public APIs for the selected plugin.

How do I add a CDT extension to my PDE project?

1. Make sure that you have the C/C++ Development Tools SDK feature installed (Help > About > Feature Details).
2. If not, use the software update feature to install it, or download the appropriate zip file distribution from the CDT update site.
3. Open the Plugin.xml file for your PDE project.
4. On the "Dependencies" tab, add a dependency on one or more of the CDT plugins in the "Required Plug-ins list", for example org.eclipse.cdt.managedbuilder.core
5. On the "Extensions" tab, any extension points supplied by the plugins you specified as required should now be visible in the list.

How do I add an Error Parser (or The project seems to build file, but doesn't parse my error output what can I do?)

Its little easy to develop a new error parser for ur BuildTool. Create an Extension for org.eclipse.cdt.core.ErrorParser

<extension
  id="NewErrorParser"
  name="New Error Parser"
  point="org.eclipse.cdt.core.ErrorParser">
  <errorparser
      class="com.xxx.ErrorParser.NewErrorParser">
  </errorparser>
</extension>

have a look at the source code for (CDT GNU C/C++ Error Parser) GCCErrorParser.java . Then write a new class NewErrorParser.

How do I add a Cross platform debugger?

The ELF parser only recognizes a fixed set of architectures. If it is not recognized as a valid type then it is recognized as "none".

E.g. To create an "AVR" aware debugger, create a plugin with the following extension:

<plugin>
  <extension
        point="org.eclipse.cdt.debug.core.CDebugger">
     <debugger
           platform="native"
           name="AVR GDB Debugger"
           modes="run,attach"
           cpu="none,avr"
           class="org.eclipse.cdt.debug.mi.core.GDBServerDebugger"
           id="org.eclipse.cdt.debug.mi.core.GDBServerCDebugger">
     </debugger>
  </extension>
</plugin>

The "cpu="none,avr"" part is of course the magical stuff...

I am developing a plug-in that requires a parsing a c file and obtaining the information such as method signatures, parameter types etc. How can I do this using the CDT parser?

To use the parser, all you need to do is put cdtparser.jar in your class path and code away. As an example, here is how the CDT Core Model instantiates and uses an IParser to build its model.

 IProject currentProject = null;
 boolean hasCppNature = true;
 String code = ""; //$NON-NLS-1$

 // get the current project
 if (translationUnit != null && translationUnit.getCProject() != null) {
 	currentProject = translationUnit.getCProject().getProject();
 }
 // check the project's nature
 if( currentProject != null )
 {
 	hasCppNature = CoreModel.hasCCNature(currentProject);
 }
 // get the code to parse
 try{
 	code = translationUnit.getBuffer().getContents();
 } catch (CModelException e) {

 }
 // use quick or structural parse mode
 ParserMode mode = quickParseMode ? ParserMode.QUICK_PARSE : ParserMode.STRUCTURAL_PARSE;
 if(quickParseMode)
 	quickParseCallback = ParserFactory.createQuickParseCallback();
 else
 	quickParseCallback = ParserFactory.createStructuralParseCallback();

 // pick the language
 ParserLanguage language = hasCppNature ? ParserLanguage.CPP : ParserLanguage.C;
 
 // create the parser
 IParser parser = null;
 try
 {
 	IScannerInfo scanInfo = new ScannerInfo();
 	IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(currentProject);
 	if (provider != null){
 		IScannerInfo buildScanInfo = provider.getScannerInformation(currentProject);
 		if (buildScanInfo != null){
 			scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
 		}
 	}
 
 	parser = ParserFactory.createParser(
 		ParserFactory.createScanner(
 			new StringReader( code ),
 			(translationUnit.getUnderlyingResource() != null ?
 					translationUnit.getUnderlyingResource().getLocation().toOSString() :
 					""), //$NON-NLS-1$
 			scanInfo,
 			mode,
 			language,
 			quickParseCallback,
 			quickParseMode ? new NullLogService() : ParserUtil.getScannerLogService(), null)
 		,quickParseCallback,
 		mode,
 		language,
 		ParserUtil.getParserLogService() );
 }
 catch( ParserFactoryError pfe )
 {
 	throw new ParserException( CCorePlugin.getResourceString("CModelBuilder.Parser_Construction_Failure")); //$NON-NLS-1$
 }
 // call parse
 hasNoErrors = parser.parse();
 if( (!hasNoErrors) && throwExceptionOnError )
 	throw new ParserException(CCorePlugin.getResourceString("CModelBuilder.Parse_Failure")); //$NON-NLS-1$
 return quickParseCallback.getCompilationUnit();

Here's a quick description of the ParserFactory interface methods you require:

/**
 * @param scanner tokenizer to retrieve C/C++ tokens
 * @param callback the callback that reports results to the client
 * @param mode the parser mode you wish to use
 * @param language C or C++
 * @param log a log utility to output errors
 * @return
 * @throws ParserFactoryError - erroneous input provided
 */
 public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError;
 /**
 * @param input the java.io.Reader that reads the source-code input you want parsed
 * @param fileName the absolute path of the file you are parsing (necessary for determining location of local inclusions)
 * @param config represents the include-paths and preprocessor definitions you wish to initialize the scanner with
 * @param mode the parser mode you wish to use
 * @param language C or C++
 * @param requestor the callback that reports results to the client
 * @param log a log utility to output errors
 * @param workingCopies a java.util.List of IWorkingCopy buffers if you wish for include files to use CDT Working Copies rather than saved files
 * @return
 * @throws ParserFactoryError - erroneous input provided
 */
 public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService log, List workingCopies ) throws ParserFactoryError;

For other information you can perhaps attach to the CVS repository @ dev.eclipse.org in order to see the rest of the code. The repository path is /home/tools and you can attach anonymously to get the source.

Missing org.eclipse.cdt.templateengine

if you are reading How to register a project template with CDT, the correct dependencies should be org.eclipse.cdt.core and org.eclipse.cdt.ui, you are probably reading an outdated documentation.

What are some areas that are not complete

This is an endless list, but here are a few examples:

  • Source code formatting
  • Integration with profiler
  • Refactoring engine
  • Full DOM read/write

In addition to submitting fixes, how else can I contribute to the CDT Project?

One initially thinks of submitting patches and enhancing components as the best way to contribute. However, there are many other valuable ways to get involved and help.

  • You can participate in the newsgroups. There are many questions that arise on the newsgroup; you can use your eclipse experience to help others.
  • You can report bugs.
  • You can develop your own plug-ins and provide feedback based on your experience.
  • You can write articles.
  • But the most important contribution you can make to the success of CDT (or eclipse) is to build real, useful tool plugins for CDT (or eclipse) that solve real problems for users - either as commercial products or open source projects. Take a look at committing to CDT development to learn more about what's involved in contributing on a deeper level.