I have a large existing c++ codebase. Typically the users of the codebase edit the source with gvim, but we'd like to start using the nifty IDE features in Eclipse. The codebase has an extensive directory hierarchy, but the source files use include directives without paths due to some voodoo we use in our build process. When I link the source to my project in Eclipse, the indexer complains that it can't find any header files (because we don't specify paths in our includes.) If I manually add the directories from the workspace to the include path then everything works wonderfully, but obviously adding hundreds of directories manually isn't feasible. Would there be a simple method to tell Eclipse to look anywhere in the project for the include files without having to add them one by one? If not, then can anyone suggest a good starting place, like what classes to extend, for writing a plugin to just scan the project at creation/modification and programatically add all directories to the include path?
我有一个很大的现有c ++代码库。通常,代码库的用户使用gvim编辑源代码,但我们想开始在Eclipse中使用漂亮的IDE功能。代码库具有广泛的目录层次结构,但由于我们在构建过程中使用了一些伏都教,源文件使用包含指令而没有路径。当我在Eclipse中将源链接到我的项目时,索引器抱怨它找不到任何头文件(因为我们没有在我们的包中指定路径。)如果我手动将工作区中的目录添加到包含路径然后一切都运行得很好,但显然手动添加数百个目录是不可行的。是否有一种简单的方法可以让Eclipse在项目的任何地方查找包含文件,而无需逐个添加它们?如果没有,那么任何人都可以建议一个良好的起点,比如要扩展的类,编写插件只是在创建/修改时扫描项目并以编程方式将所有目录添加到包含路径中?
4 个解决方案
#1
2
This feature has already been implemented in the current CDT development stream and will be available in CDT 6.0, which will be released along with Eclipse 3.5 in June 2009.
此功能已在当前的CDT开发流中实现,并将在CDT 6.0中提供,CDT 6.0将于2009年6月与Eclipse 3.5一起发布。
Basically if you have an #include and the header file exists somewhere in your project then CDT will be able to find it without the need to manually set up include paths.
基本上,如果你有一个#include并且头文件存在于项目的某个地方,那么CDT将能够找到它而无需手动设置包含路径。
If you need the feature now you can download and install the latest CDT development build.
如果您现在需要此功能,则可以下载并安装最新的CDT开发版本。
Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=21356
Latest CDT 6.0 Builds: http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html
Eclipse Bugzilla:https://bugs.eclipse.org/bugs/show_bug.cgi?id = 21356最新的CDT 6.0版本:http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html
#2
5
The way that CDT manages build paths is by looking at the .cdtbuild xml file in the base of your projects directory (it might be a different name on windows... not sure)
CDT管理构建路径的方式是查看项目目录底部的.cdtbuild xml文件(它可能是Windows上的不同名称......不确定)
In this you should see something like
在这你应该看到类似的东西
<option id="gnu.c.compiler.option.include.paths....>
<listoptionValue builtIn="false" value=""${workspace_loc:/some/path}$quot;" />
<listOptionValue ... />
...
</option>
this is where all the build paths that you configure in the gui are placed. It should be pretty easy to add all the directories to this using a simple perl script to walk the project and generate all the listOptionValue entries.
这是您在gui中配置的所有构建路径的位置。使用简单的perl脚本将所有目录添加到此处应该非常容易,以便遍历项目并生成所有listOptionValue条目。
This is obviously not the ideal method. But im curious, what build system are you migrating from, if it is make based you should be able to get eclipse to use your make files.
这显然不是理想的方法。但我很好奇,你从哪个构建系统迁移,如果它是基于make的,你应该能够让eclipse使用你的make文件。
#3
1
From reading the this Eclipse CDT FAQ entry, it sounds like Eclipse can automatically generate a list of include directories if you start your build from within Eclipse and if your build outputs the gcc
/ g++
commands before actually starting gcc
/ g++
. You can change how Eclipse starts a build by going under Project Properties then selecting the C/C++ Build category and looking for the Build Command option on the right side of the dialog.
通过阅读此Eclipse CDT FAQ条目,听起来Eclipse可以自动生成包含目录的列表,如果您从Eclipse中开始构建,并且如果您的构建在实际启动gcc / g ++之前输出gcc / g ++命令。您可以通过在Project Properties下选择C / C ++ Build类别并在对话框右侧查找Build Command选项来更改Eclipse启动构建的方式。
#4
0
Depending on the amount of voodoo you are doing in your build process, then Eclipse may not be able to correctly parse your source files, especially if you have similarly named headers for different source files. If you really want to take full advantage of Eclipse you're going to need to make sure that with whatever setup you have you aren't going to be confusing the parser. Personally I would recommend having a simple layout and build process.
根据您在构建过程中执行的voodoo数量,Eclipse可能无法正确解析源文件,尤其是如果您具有针对不同源文件的类似命名的标头。如果你真的想要充分利用Eclipse,你将需要确保无论你有什么设置,你都不会混淆解析器。我个人建议有一个简单的布局和构建过程。
As for the question at hand, adding the directories one by one is pretty much your best bet.
至于手头的问题,逐个添加目录几乎是你最好的选择。
#1
2
This feature has already been implemented in the current CDT development stream and will be available in CDT 6.0, which will be released along with Eclipse 3.5 in June 2009.
此功能已在当前的CDT开发流中实现,并将在CDT 6.0中提供,CDT 6.0将于2009年6月与Eclipse 3.5一起发布。
Basically if you have an #include and the header file exists somewhere in your project then CDT will be able to find it without the need to manually set up include paths.
基本上,如果你有一个#include并且头文件存在于项目的某个地方,那么CDT将能够找到它而无需手动设置包含路径。
If you need the feature now you can download and install the latest CDT development build.
如果您现在需要此功能,则可以下载并安装最新的CDT开发版本。
Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=21356
Latest CDT 6.0 Builds: http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html
Eclipse Bugzilla:https://bugs.eclipse.org/bugs/show_bug.cgi?id = 21356最新的CDT 6.0版本:http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html
#2
5
The way that CDT manages build paths is by looking at the .cdtbuild xml file in the base of your projects directory (it might be a different name on windows... not sure)
CDT管理构建路径的方式是查看项目目录底部的.cdtbuild xml文件(它可能是Windows上的不同名称......不确定)
In this you should see something like
在这你应该看到类似的东西
<option id="gnu.c.compiler.option.include.paths....>
<listoptionValue builtIn="false" value=""${workspace_loc:/some/path}$quot;" />
<listOptionValue ... />
...
</option>
this is where all the build paths that you configure in the gui are placed. It should be pretty easy to add all the directories to this using a simple perl script to walk the project and generate all the listOptionValue entries.
这是您在gui中配置的所有构建路径的位置。使用简单的perl脚本将所有目录添加到此处应该非常容易,以便遍历项目并生成所有listOptionValue条目。
This is obviously not the ideal method. But im curious, what build system are you migrating from, if it is make based you should be able to get eclipse to use your make files.
这显然不是理想的方法。但我很好奇,你从哪个构建系统迁移,如果它是基于make的,你应该能够让eclipse使用你的make文件。
#3
1
From reading the this Eclipse CDT FAQ entry, it sounds like Eclipse can automatically generate a list of include directories if you start your build from within Eclipse and if your build outputs the gcc
/ g++
commands before actually starting gcc
/ g++
. You can change how Eclipse starts a build by going under Project Properties then selecting the C/C++ Build category and looking for the Build Command option on the right side of the dialog.
通过阅读此Eclipse CDT FAQ条目,听起来Eclipse可以自动生成包含目录的列表,如果您从Eclipse中开始构建,并且如果您的构建在实际启动gcc / g ++之前输出gcc / g ++命令。您可以通过在Project Properties下选择C / C ++ Build类别并在对话框右侧查找Build Command选项来更改Eclipse启动构建的方式。
#4
0
Depending on the amount of voodoo you are doing in your build process, then Eclipse may not be able to correctly parse your source files, especially if you have similarly named headers for different source files. If you really want to take full advantage of Eclipse you're going to need to make sure that with whatever setup you have you aren't going to be confusing the parser. Personally I would recommend having a simple layout and build process.
根据您在构建过程中执行的voodoo数量,Eclipse可能无法正确解析源文件,尤其是如果您具有针对不同源文件的类似命名的标头。如果你真的想要充分利用Eclipse,你将需要确保无论你有什么设置,你都不会混淆解析器。我个人建议有一个简单的布局和构建过程。
As for the question at hand, adding the directories one by one is pretty much your best bet.
至于手头的问题,逐个添加目录几乎是你最好的选择。