Finding an entire project for inclusion in the Eclipse CDT

I have a large existing C ++ code base. As a rule, users of the codebase edit the source using gvim, but we would like to start using the excellent IDE features in Eclipse. The codebase has an extensive directory hierarchy, but the source files use include directives with no paths due to some voodoo that we use in our build process. When I link the source to my project in Eclipse, the indexer complains that he cannot find the header files (because we do not specify the paths in our included ones.) If I manually add directories from the workspace to the inclusion path, everything works wonderfully, but, obviously adding hundreds of directories manually is not possible. Would there be an easy way to tell Eclipse to search anywhere in the project for included files without adding them one by one? If not, can anyone suggest a good starting place, for example, which classes to extend, for writing a plugin, just to scan the project when creating / modifying and add all directories to the include path programmatically?

+7
c ++ eclipse eclipse-cdt
source share
4 answers

This feature has already been implemented in the current CDT development stream and will be available in CDT 6.0, which will be released with Eclipse 3.5 in June 2009.

Basically, if you have #include and the header file exists somewhere in your project, then the CDT will be able to find it without having to manually set the included paths.

If you need this feature, you can download and install the latest development CDT.

Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=21356 <w> Recent CDT 6.0 Builds: http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html p>

+2
source share

The way that CDT manages build paths is to look at the .cdtbuild XML file in the base of your project directory (this may be a different name in the windows ... not sure)

In this you should see something like

<option id="gnu.c.compiler.option.include.paths....> <listoptionValue builtIn="false" value="&quot;${workspace_loc:/some/path}$quot;" /> <listOptionValue ... /> ... </option> 

here are all the build paths that you configure in gui. It's easy enough to add all the directories to this using a simple perl script to go through the project and generate all the listOptionValue entries.

This is obviously not an ideal method. But they are curious what build system you are transitioning to, if this is done based on, you should be able to get eclipse to use your make files.

+5
source share

From reading this Eclipse CDT FAQ entry , it seems that Eclipse can automatically generate a list of included directories if you start building with in Eclipse, and if your assembly prints gcc / g++ commands before running gcc / g++ . You can change how Eclipse launches the build by going to Project Properties, then selecting the Build C / C ++ category and choosing the Create Command command on the right side of the dialog box.

+1
source share

Depending on the amount of voodoo you make during the build process, Eclipse may not be able to parse your source files correctly, especially if you have the same named headers for different source files. If you really want to make full use of Eclipse, you will need to make sure that you will not confuse the parser with any setting. Personally, I would recommend having a simple layout and build process.

As for the issue, adding directories one by one is your best bet.

0
source share

All Articles