I have a large existing c++ codebase. Typically the users of the codebase edit the source with gvim, but we'd like to start using the nifty IDE features in Eclipse. The codebase has an extensive directory hierarchy, but the source files use include directives without paths due to some voodoo we use in our build process. When I link the source to my project in Eclipse, the indexer complains that it can't find any header files (because we don't specify paths in our includes.) If I manually add the directories from the workspace to the include path then everything works wonderfully, but obviously adding hundreds of directories manually isn't feasible. Would there be a simple method to tell Eclipse to look anywhere in the project for the include files without having to add them one by one? If not, then can anyone suggest a good starting place, like what classes to extend, for writing a plugin to just scan the project at creation/modification and programatically add all directories to the include path?
Simply right click on the file > go to Resource Configurations > Reset to Default... Your header files will be found now, provided that you've written the correct include paths in your project settings.
In Eclipse, go to the "File" menu, then "New", then "C++ Project" if it's there. If not, choose "Project", then find "C/C++" in the list of wizards, click the "+" sign to expand it, and choose "C++ Project". A dialog box will ask whether to open the C/C++ perspective. Answer "yes", and remember this decision.
To use Eclipse for C/C++ programming, you need a C/C++ compiler. On Windows, you could install either MinGW GCC or Cygwin GCC. Choose MinGW if you are not sure, because MinGW is lighter and easier to install, but having less features.
The C/C++ Development Toolkit (CDT) is a set of Eclipse plug-ins that provide C and C++ extensions to the Eclipse workbench. For more information about Eclipse, see Workbench User Guide > Concepts > Workbench. The CDT provides a C/C++ IDE that simplifies many of the same tools that you can use from the command line.
The way that CDT manages build paths is by looking at the .cdtbuild xml file in the base of your projects directory (it might be a different name on windows... not sure)
In this you should see something like
<option id="gnu.c.compiler.option.include.paths....>
<listoptionValue builtIn="false" value=""${workspace_loc:/some/path}$quot;" />
<listOptionValue ... />
...
</option>
this is where all the build paths that you configure in the gui are placed. It should be pretty easy to add all the directories to this using a simple perl script to walk the project and generate all the listOptionValue entries.
This is obviously not the ideal method. But im curious, what build system are you migrating from, if it is make based you should be able to get eclipse to use your make files.
This feature has already been implemented in the current CDT development stream and will be available in CDT 6.0, which will be released along with Eclipse 3.5 in June 2009.
Basically if you have an #include and the header file exists somewhere in your project then CDT will be able to find it without the need to manually set up include paths.
If you need the feature now you can download and install the latest CDT development build.
Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=21356
Latest CDT 6.0 Builds: http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With