大型 C++ 项目推荐的 Eclipse CDT 配置是什么(索引器需要永远)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9565125/
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
What's the recommended Eclipse CDT configuration for big C++ project (indexer takes forever)
提问by krico
I'm working on some legacy C++ code written using "vi" and "emacs" and I am trying to build an eclipse CDT setup to maintain it (on linux). The two main problems I've been facing are that the indexing takes very long (over 4h) and that even once that's finished, eclipse is barely responsive.
我正在处理一些使用“vi”和“emacs”编写的遗留 C++ 代码,我正在尝试构建一个 eclipse CDT 设置来维护它(在 linux 上)。我一直面临的两个主要问题是索引需要很长时间(超过 4 小时),而且即使完成,eclipse 也几乎没有响应。
The code base is structured in a "3-4 level deep" manner:
代码库以“3-4 级深度”的方式构建:
/system/${category}/${library}/
/server/${serverName}/${component}/
Example:
例子:
/system/CORE/CommandLine/*.cpp
/system/CORE/Connection/*.cpp
...
/server/Authentication/DB/Objects/*.cpp
/server/Authentication/Main/*.cpp
There are about 200 "modules" under /system/* and around 50 under /server/Authentication/*. There is also an amazingly convoluted make system with 20 years worth of make-codewritten by people who wanted to showoff their make abilities :-)
/system/* 下大约有 200 个“模块”,/server/Authentication/* 下大约有 50 个。还有一个非常复杂的 make 系统,里面有 20 年的make-code,这些代码是由想要炫耀自己 make 能力的人编写的 :-)
I've tried two approaches so far
到目前为止我已经尝试了两种方法
1) Two eclipse cdt projects, namely /system and /Authentication
1)两个eclipse cdt项目,分别是/system和/Authentication
2) One eclipse cdt project per "module" ending up with +200 modules. I even calculated dependencies between modules.
2) 每个“模块”有一个 Eclipse cdt 项目,最终有 200 个模块。我什至计算了模块之间的依赖关系。
In both approaches, indexing takes very long. On approach 1) I get quite a few problems with non-resolved dependencies. With approach 2) eclipse is barely responsive, when I ctrl+click a function I can go for a coffee and come back before it responds...
在这两种方法中,索引都需要很长时间。在方法 1) 中,我遇到了很多未解决的依赖项的问题。使用方法 2) eclipse 几乎没有响应,当我 ctrl+click 一个功能时,我可以去喝杯咖啡,然后在它响应之前回来......
Anyone out there has worked with big projects like these? What do you suggest?
有没有人做过这样的大项目?你有什么建议?
回答by ks1322
General recommendation here is to provide more RAM for Eclipse. First, you will need to tweak your eclipse.ini
configuration file as the default one is not suitable for big projects. Here is my eclipse.ini
file:
这里的一般建议是为 Eclipse 提供更多 RAM。首先,您需要调整您的eclipse.ini
配置文件,因为默认配置文件不适用于大型项目。这是我的eclipse.ini
文件:
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.cpp.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512M
-Xmx4096M
-XX:PermSize=256M
-XX:MaxPermSize=512M
Here I used -Xmx4096M
to provide 4Gb of RAM.
这里我曾经-Xmx4096M
提供 4Gb 的 RAM。
To improve responsiveness you will also need to configure Indexer Cache limits. I recommend to increase all parameters by 2-3 times, depending on project size.
为了提高响应能力,您还需要配置索引器缓存限制。我建议将所有参数增加 2-3 倍,具体取决于项目大小。
回答by Bemipefe
Using the Project resource filtershelped me a lot. I removed from the project tree folders which I didn't want either to modify or to submit to indexing.
使用项目资源过滤器对我帮助很大。我从不想修改或提交索引的项目树文件夹中删除。
To create a new filter just right click on the project and then open the Propertiespanel then reach Resource -> Resource Filters
要创建新过滤器,只需右键单击该项目,然后打开“属性”面板,然后到达“资源”->“资源过滤器”
Sometimes if your project sources are too big (ex: about 5GB ) you need to use a filter otherwise the indexing process never end correctly.
有时,如果您的项目源太大(例如:大约 5GB ),您需要使用过滤器,否则索引过程永远不会正确结束。