How can I get Eclipse to index an entire C/C++ source tree that contains multiple "make projects"?

Gordon picture Gordon · Sep 1, 2011 · Viewed 79.1k times · Source

I'm having trouble getting Eclipse to index my source code. I'm using Eclipse Helios on Windows XP at the moment.

I have a directory called src. Within it, I have a bunch of dirs, something like this:

 src
   -include (common headers)
   -lib
     -libIO (source code for this library)
     -libGUI  (source code for this library)
   -pgms
     -pgm1  (source code and headers for this pgm)
     -pgm2  (source code and headers for this pgm)

Each leaf has its own Makefile. There is no top-level Makefile in src. pgm1 can and does include files from include and lib/libIO and lib/libGUI.

Basically, I want Eclipse to index my entire src directory, without having to set up a C/C++ project for every leaf in my tree. I can't seem to find a way to make this happen.

Here's my symptoms; what I'm trying to solve for:

When editing source in the pgm1 dir, it references functions that are declared in my include dir header files and defined in source files found in lib/libIO.

However, when I press F3 to get to the declaration of a function, Eclipse says "Could not find symbol 'X' in index". I can't seem to get Eclipse to find either the header declaration or the source definition for the method under my cursor (like the Java module does perfectly). Is this possible?

Answer

MHD picture MHD · Jul 12, 2012

I had exactly same issue as OP but for some reason the menus in Eclipse I was using (Helios Service Release 2) were not "Go to Properties -> C/C++ General -> Paths and Symbols -> Source Location.".

The way I fixed the issue was :

  • in C/C++ view, right-click on top project name;
  • in the menu, select New->C++ Project;
  • in the window that appears, select Convert to and then select C++ project;
  • click OK to close the window.

Eclipse will start indexing right away. Depending on the size of source tree it may take a while but you will have the indexing working finally after that.