C++ Eclipse 索引不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11357009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse indexing not working
提问by liaK
I am using CDT in Eclipse 3.5.2 Galileo in Ubuntu.
我在 Ubuntu 的 Eclipse 3.5.2 Galileo 中使用 CDT。
My eclipse's indexer doesn't work at times. By that I mean when I ctrl
click a function it says Could not find symbol in index
. Also, F3 button click results in the same error message. Actually most of the places it is not working and works in very few places.
我的日食索引器有时不工作。我的意思是当我ctrl
单击一个函数时,它会显示Could not find symbol in index
. 此外,单击 F3 按钮会导致相同的错误消息。实际上,它在大多数地方都不起作用,并且在很少的地方起作用。
I have seen some other versions of Eclipse where under File menu a menu item listed for Indexing. Like File->Indexer->Rebuild.... But in my File menu there is no such menu item for the Indexer.
我见过一些其他版本的 Eclipse,其中在 File 菜单下列出了一个用于索引的菜单项。像文件->索引器->重建...。但在我的文件菜单中,索引器没有这样的菜单项。
Will the only way be to use some other release of Eclipse or am missing something? Any pointers regarding this would be helpful.
唯一的方法是使用其他版本的 Eclipse 还是遗漏了什么?任何有关这方面的指示都会有所帮助。
回答by sree
In my case nothing has worked and at last I did the following:
就我而言,没有任何效果,最后我做了以下事情:
1) Close the project
2) Delete the project(do not check from disk option)
3) create new project with existing code(use the deleted project path)
4) Successfully indexed my c++ code
回答by B?ови?
To add paths containing code to parse, follow these steps :
1. Right click on the project
2. Select Properties
3. Go to C/C++ General
4. Go to Path and Symbols
5. If the paths are missing, add paths.
要添加包含要解析的代码的路径,请执行以下步骤:
1. 右键单击项目
2. 选择属性
3. 转到 C/C++ 常规
4. 转到路径和符号
5. 如果缺少路径,请添加路径。
To re-parse the code follow these steps :
1. Right click on the project
2. Select Index
3. Rebuild
要重新解析代码,请执行以下步骤:
1. 右键单击项目
2. 选择索引
3. 重建
If this doesn't work, then you are out of luck. c++ is very difficult language to parse.
如果这不起作用,那么你就不走运了。c++ 是很难解析的语言。
回答by user4786271
If your indexer is stuck and it hangs for infinite time, you can delete the indexer related files of your project from .metadata
. Make sure eclipse is not running in the meanwhile.
如果您的索引器卡住并无限期挂起,您可以从.metadata
. 确保 eclipse 没有同时运行。
The .metadata
directory is located as a hidden folder in the path of your workspace.
该.metadata
目录位于工作区路径中的隐藏文件夹中。
There you can navigate to:
在那里您可以导航到:
<workspace_path>/.metadata/.plugins/org.eclipse.core.runtime/.settings/
<workspace_path>/.metadata/.plugins/org.eclipse.core.runtime/.settings/
Inside the .settings/
directory there are .prefs
files which store the preferences of each project individually.
在.settings/
目录中,有一些.prefs
文件分别存储了每个项目的首选项。
For example: org.eclipse.cdt.core.prj-test-project.prefs
stores the preferences of the project test-project
例如:org.eclipse.cdt.core.prj-test-project.prefs
存储项目test-project的偏好
Open this file with the text editor and remove all the lines starting with indexer
. This will reset the indexer settings for this specific project to the default.
使用文本编辑器打开此文件并删除所有以indexer
. 这会将这个特定项目的索引器设置重置为默认值。
Alternatively, you can remove all the lines starting with indexer
from org.eclipse.cdt.core.prefs
; doing this will reset the indexer settings for the whole workspace.
或者,您可以删除所有以indexer
from开头的行org.eclipse.cdt.core.prefs
;这样做将重置整个工作区的索引器设置。
回答by dimo414
I believe you can clear the index by running:
我相信您可以通过运行来清除索引:
rm .metadata/.plugins/org.eclipse.jdt.core/*.index
And then restarting Eclipse. It will then rebuild its index.
然后重新启动Eclipse。然后它会重建它的索引。
This worked for me in a Java project, but I imagine its the same index for all (most?) project types.
这在 Java 项目中对我有用,但我想它对所有(大多数?)项目类型都有相同的索引。
回答by Saadat
For me this worked:
对我来说这有效:
- Right click and close the project
- Open the project again
- Right click and select Index->Rebuild
- 右键单击并关闭项目
- 再次打开项目
- 右键单击并选择索引->重建
I hope it helps anybody.
我希望它可以帮助任何人。
回答by Shibu J
- Right click on the project.
- Select
New->Convert
to aC++
Project. Select your configuration. And then Next - Indexer will start indexing all the files.
- 右键单击项目。
- 选择
New->Convert
一个C++
项目。选择您的配置。然后下一步 - 索引器将开始索引所有文件。
回答by kapilddit
- Execute eclipse.exe -clean -refreshwhere the eclipse is installed.
- Create a new C/C++ Project in Eclipse with Given Source code folder path. (Not with New Project based on existing workspace)
- 在安装eclipse 的地方执行eclipse.exe -clean -refresh。
- 使用给定的源代码文件夹路径在 Eclipse 中创建一个新的 C/C++ 项目。(不适用于基于现有工作区的新项目)
Above steps worked for me.
以上步骤对我有用。
回答by paarandika
You can try rebuilding the index.
Right-click on the project in Project View. Then Index -> Rebuild
.
您可以尝试重建索引。在项目视图中右键单击项目。然后Index -> Rebuild
。
回答by Flo
Here is the solution I used after Project->C++ Index->Rebuild
failed. This trick avoid deleting your current project :
这是我Project->C++ Index->Rebuild
失败后使用的解决方案。此技巧可避免删除您当前的项目:
1) Copy the current project (Right click->Copy from Project Explorer)
2) Paste it (Right click->Paste from Project Explorer) and give the copy another name
3) The indexer should now start and index both projects
4) When indexation is complete, you can delete the copy
PS: Make sure your original project is an actual C++ Project or this will obviously not work.
PS:确保您的原始项目是实际的 C++ 项目,否则这显然不起作用。
回答by vr286
Convert a?project?to C or?C++?nature:
将项目转换为 C 或 C++ 性质:
Right click on project
: New > ?Convert?to C/C++?Project
Right click on project
: New > ?Convert?to C/C++?Project
In "Convert?to C or C++"
: Choose C/C++?Project
In "Convert?to C or C++"
: 选择C/C++?项目
In "Project options":
Check "Specify Project Type"
In "Project options":
勾选“指定项目类型”
...Project Type:
Choose "Makefile project"
...Project Type:
选择“Makefile项目”
...Toolchains:
Gross GCC
...Toolchains:
总海湾合作委员会