Reputation: 1210
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?
Upvotes: 26
Views: 87055
Reputation: 1060
I am using Eclipse Neon 3, here's the solution that worked for me :
It can take some time to finish indexing, it depends on your project size.
Upvotes: 2
Reputation: 3
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.
Upvotes: 0
Reputation: 11
I have experienced problems with the indexer of Eclipse Luna when there was an unresolved friend declaration in the class declaration - it seems then that the indexer skipped indexing the rest of that class, and all references to it was shown as unresolved by the indexer.
Solution: removed the unresolved friend declaration (in my case, it was legacy code that was no longer needed).
Upvotes: 1
Reputation: 56
I am using
Eclipse IDE for C/C++ Linux Developers
Version: Helios Service Release 2 Build id: 20110218-0911
I followed the suggestions above and in addition I had to mark all referenced projects (with in the work space) using project properties->Project references
Upvotes: 0
Reputation: 21
Indexing of files and variables under different flags is always complicated when we have a huge project, lot of files and more importantly lot of different build options. I prefer playing around with the Indexer option to help me browse the entire code. You can find it : Project Properties>C/C++ General/Indexer.
You can choose "Enable project specific settings"
Then it's up to you to choose the options you want for your project. For a particular build we can choose "Use active build configuration" so that only the files and MACROS are considered which are used by the build script. Or Index all source files in the entire project.
Upvotes: 2
Reputation: 1
If the project is already converted to C/C++ and still the index is not working you can right click on the project and Index and rebuild. The project will start indexing right away.
Upvotes: 0
Reputation: 1
In Coocox IDE (Eclipse + gcc) the problem is resolved by going from file menu Edit > Preferences > C/C++ / Indexer > Build configuration for Indexer set to Active build configuration and the rebuild the project (Ctrl R).
Upvotes: 0
Reputation: 31
in the project explorer panel, right click the project you want to re-index, then select index, then select the action you want
Upvotes: 3
Reputation: 919
Exit Eclipse. In workspace go to ".metadata/.plugins/org.eclipse.cdt.core" and delete everything in there.
Upvotes: 4
Reputation: 111
I faced similar situation. I solved it in this way: right-click the project in project View-->select Index-->rebuild.
Upvotes: 11
Reputation: 321
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 :
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.
Upvotes: 32
Reputation: 1210
I managed to solve this thanks to comments here.... I ended up recreating my project. I used the Import method to download a project from CVS, and told it to use the New Project wizard to do so. When I got the New Project dialog, I told it this was a C++ Project, and the indexing now works fine.
I still wish I could index files without having to attach a specific project type to it, but at least I found an answer.
Thanks for the help all.
Upvotes: 5
Reputation: 7455
Please try the following (my project is set up differently, so I am not sure this will work for you).
Go to Properties -> C/C++ General -> Paths and Symbols -> Source Location.
Do you see your source folder there?
I observe this behavior: When I add a source folder and then exclude it from build, it disappears from the above list. After that the folder is no longer indexed. Re-adding it to "Source Location" solves the problem: the folder is now indexed; remains excluded from build (as intended); is visible among source locations.
I believe it is a bug -- excluding a source folder from build should not remove it from source locations list.
Upvotes: 0