如何让Eclipse索引包含多个“make项目”的整个C/ c++源树?

时间:2022-09-01 14:31:49

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

我很难让Eclipse索引我的源代码。目前我正在Windows XP上使用Eclipse Helios。

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

我有一个目录叫src。里面有一串dirs,类似于:

 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.

每个叶子都有自己的Makefile。src中没有*Makefile。pgm1可以并且确实包含来自include和lib/libIO和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.

基本上,我希望Eclipse为我的整个src目录建立索引,而不需要为我的树中的每个叶子设置一个C/ c++项目。我似乎找不到实现这一目标的方法。

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.

在pgm1目录中编辑源代码时,它引用在我的include目录头文件中声明的函数,并在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?

但是,当我按F3到达一个函数的声明时,Eclipse说“不能在索引中找到符号‘X’”。我似乎无法让Eclipse在我的光标下找到方法的头声明或源定义(就像Java模块做的那样)。这是可能的吗?

13 个解决方案

#1


27  

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.".

我遇到了与OP完全相同的问题,但出于某种原因,我使用的Eclipse中的菜单(Helios服务发行版2)不是“到属性——> C/ c++ General——>路径和符号——>源位置”。

The way I fixed the issue was :

我解决这个问题的方法是:

  • in C/C++ view, right-click on top project name;
  • 在C/ c++视图中,右键单击顶部项目名称;
  • in the menu, select New->C++ Project;
  • 在菜单中,选择New-> c++项目;
  • in the window that appears, select Convert to and then select C++ project;
  • 在出现的窗口中,选择Convert to,然后选择c++项目;
  • click OK to close the window.
  • 单击OK关闭窗口。

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.

Eclipse将立即开始索引。根据源树的大小,可能需要一段时间,但是之后索引将最终工作。

#2


10  

I faced similar situation. I solved it in this way: right-click the project in project View-->select Index-->rebuild.

我也遇到了类似的情况。我用这种方式解决了这个问题:在项目视图中右键单击项目——>选择索引——>重建。

#3


4  

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.

我设法解决这个感谢评论....最后我重新创建了我的项目。我使用Import方法从CVS下载一个项目,并告诉它使用New project向导来下载。当我得到新的项目对话框时,我告诉它这是一个c++项目,而索引现在运行良好。

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.

谢谢大家的帮助。

#4


3  

Exit Eclipse. In workspace go to ".metadata/.plugins/org.eclipse.cdt.core" and delete everything in there.

退出Eclipse。在工作区中,转到“.metadata/.plugins/org. eclipsee .cdt”。然后删除里面的所有东西。

#5


3  

in the project explorer panel, right click the project you want to re-index, then select index, then select the action you want

在project explorer面板中,右键单击要重新索引的项目,然后选择index,然后选择所需的操作。

#6


2  

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.

当我们有一个庞大的项目,很多文件,更重要的是有很多不同的构建选项时,在不同标志下的文件和变量总是很复杂的。我更喜欢使用Indexer选项来帮助我浏览整个代码。您可以找到它:项目属性>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.

然后,您可以为您的项目选择您想要的选项。对于特定的构建,我们可以选择“使用活动构建配置”,以便只考虑构建脚本使用的文件和宏。或索引整个项目中的所有源文件。

#7


1  

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.

当类声明中有一个未解决的好友声明时,我遇到了Eclipse Luna索引器的问题——似乎索引器跳过了该类的其余部分,索引器显示了对它的所有引用都是未解决的。

Solution: removed the unresolved friend declaration (in my case, it was legacy code that was no longer needed).

解决方案:删除未解析的好友声明(在我的例子中,不再需要遗留代码)。

#8


0  

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.

Go to Properties -> C/ c++ General ->路径和符号->源位置。

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.

我观察到这种行为:当我添加一个源文件夹并将其从build中排除时,它将从上面的列表中消失。之后,该文件夹不再被索引。将它重新添加到“源位置”可以解决这个问题:该文件夹现在已被索引;仍然被排除在构建之外(如预期的那样);在源位置中可见。

I believe it is a bug -- excluding a source folder from build should not remove it from source locations list.

我认为这是一个错误——从构建中排除源文件夹不应该从源位置列表中删除它。

#9


0  

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).

在Coocox IDE (Eclipse + gcc)中,问题通过从文件菜单编辑>首选项> C/ c++ / Indexer >构建配置到活动构建配置和重建项目(Ctrl R)来解决。

#10


0  

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.

如果项目已经转换为C/ c++,并且仍然没有工作,您可以右键单击项目和索引并重新构建。项目将立即开始索引。

#11


0  

I am using

我用

Eclipse IDE for C/C++ Linux Developers

用于C/ c++ Linux开发人员的Eclipse IDE

Version: Helios Service Release 2 Build id: 20110218-0911

版本:Helios服务版本2构建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

我遵循了上面的建议,而且我必须使用项目属性——>项目引用来标记所有被引用的项目(在工作空间中)

#12


0  

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.

在Eclipse Neon: New Project -> C/ c++ -> Makefile项目中,我使用了以下代码:> Next。然后导航到代码并完成项目创建。索引自动启动。

#13


0  

I am using Eclipse Neon 3, here's the solution that worked for me :

我正在使用Eclipse Neon 3,以下是对我有用的解决方案:

  • go to File
  • 去文件
  • New
  • Convert to C/C++ Autotools project then select your project and finish.
  • 转换到C/ c++ Autotools项目,然后选择您的项目和完成。

It can take some time to finish indexing, it depends on your project size.

完成索引需要一些时间,这取决于您的项目大小。

#1


27  

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.".

我遇到了与OP完全相同的问题,但出于某种原因,我使用的Eclipse中的菜单(Helios服务发行版2)不是“到属性——> C/ c++ General——>路径和符号——>源位置”。

The way I fixed the issue was :

我解决这个问题的方法是:

  • in C/C++ view, right-click on top project name;
  • 在C/ c++视图中,右键单击顶部项目名称;
  • in the menu, select New->C++ Project;
  • 在菜单中,选择New-> c++项目;
  • in the window that appears, select Convert to and then select C++ project;
  • 在出现的窗口中,选择Convert to,然后选择c++项目;
  • click OK to close the window.
  • 单击OK关闭窗口。

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.

Eclipse将立即开始索引。根据源树的大小,可能需要一段时间,但是之后索引将最终工作。

#2


10  

I faced similar situation. I solved it in this way: right-click the project in project View-->select Index-->rebuild.

我也遇到了类似的情况。我用这种方式解决了这个问题:在项目视图中右键单击项目——>选择索引——>重建。

#3


4  

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.

我设法解决这个感谢评论....最后我重新创建了我的项目。我使用Import方法从CVS下载一个项目,并告诉它使用New project向导来下载。当我得到新的项目对话框时,我告诉它这是一个c++项目,而索引现在运行良好。

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.

谢谢大家的帮助。

#4


3  

Exit Eclipse. In workspace go to ".metadata/.plugins/org.eclipse.cdt.core" and delete everything in there.

退出Eclipse。在工作区中,转到“.metadata/.plugins/org. eclipsee .cdt”。然后删除里面的所有东西。

#5


3  

in the project explorer panel, right click the project you want to re-index, then select index, then select the action you want

在project explorer面板中,右键单击要重新索引的项目,然后选择index,然后选择所需的操作。

#6


2  

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.

当我们有一个庞大的项目,很多文件,更重要的是有很多不同的构建选项时,在不同标志下的文件和变量总是很复杂的。我更喜欢使用Indexer选项来帮助我浏览整个代码。您可以找到它:项目属性>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.

然后,您可以为您的项目选择您想要的选项。对于特定的构建,我们可以选择“使用活动构建配置”,以便只考虑构建脚本使用的文件和宏。或索引整个项目中的所有源文件。

#7


1  

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.

当类声明中有一个未解决的好友声明时,我遇到了Eclipse Luna索引器的问题——似乎索引器跳过了该类的其余部分,索引器显示了对它的所有引用都是未解决的。

Solution: removed the unresolved friend declaration (in my case, it was legacy code that was no longer needed).

解决方案:删除未解析的好友声明(在我的例子中,不再需要遗留代码)。

#8


0  

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.

Go to Properties -> C/ c++ General ->路径和符号->源位置。

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.

我观察到这种行为:当我添加一个源文件夹并将其从build中排除时,它将从上面的列表中消失。之后,该文件夹不再被索引。将它重新添加到“源位置”可以解决这个问题:该文件夹现在已被索引;仍然被排除在构建之外(如预期的那样);在源位置中可见。

I believe it is a bug -- excluding a source folder from build should not remove it from source locations list.

我认为这是一个错误——从构建中排除源文件夹不应该从源位置列表中删除它。

#9


0  

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).

在Coocox IDE (Eclipse + gcc)中,问题通过从文件菜单编辑>首选项> C/ c++ / Indexer >构建配置到活动构建配置和重建项目(Ctrl R)来解决。

#10


0  

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.

如果项目已经转换为C/ c++,并且仍然没有工作,您可以右键单击项目和索引并重新构建。项目将立即开始索引。

#11


0  

I am using

我用

Eclipse IDE for C/C++ Linux Developers

用于C/ c++ Linux开发人员的Eclipse IDE

Version: Helios Service Release 2 Build id: 20110218-0911

版本:Helios服务版本2构建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

我遵循了上面的建议,而且我必须使用项目属性——>项目引用来标记所有被引用的项目(在工作空间中)

#12


0  

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.

在Eclipse Neon: New Project -> C/ c++ -> Makefile项目中,我使用了以下代码:> Next。然后导航到代码并完成项目创建。索引自动启动。

#13


0  

I am using Eclipse Neon 3, here's the solution that worked for me :

我正在使用Eclipse Neon 3,以下是对我有用的解决方案:

  • go to File
  • 去文件
  • New
  • Convert to C/C++ Autotools project then select your project and finish.
  • 转换到C/ c++ Autotools项目,然后选择您的项目和完成。

It can take some time to finish indexing, it depends on your project size.

完成索引需要一些时间,这取决于您的项目大小。