Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 263
Gordon Avatar asked Sep 01 '11 16:09

Gordon


People also ask

How do I index a project in Eclipse?

The following has worked for me in Eclipse Neon: New Project -> C/C++ -> Makefile project with existing code -> Next. Then Navigate to the code and finish the project creation. Indexing starts automatically.

How do I create a new C project in Eclipse?

Create a new projectGo to Window → Open perspective → Other, select C/C++, and click OK. Go to File → New → C Project, and choose a name for the project (for example, Greeting ). Click Finish to accept all defaults.


1 Answers

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.

like image 199
MHD Avatar answered Sep 29 '22 17:09

MHD