Eclipse CDT新建项目模板 - 如何添加库 [英] Eclipse CDT New Project Template - How to add a library
问题描述
在Eclipse CDT Indigo中,有一个新功能允许您将新的C / C ++模板项目添加到新项目向导中。我已经弄清楚如何成功地做到这一点。我可以创建一个仅仅依赖于简单的源文件的基本项目,但现在我想创建一个CPPUnit项目,我想自动添加CPPUnit库。对于我的生活,我无法弄清楚如何实现这一目标。有没有人知道如何?
In Eclipse CDT Indigo, there is a new feature that allows you to add new C/C++ template projects to the new project wizard. I've figured out how to do this successfully up to a point. I can create a basic project that just depends on simple source files but now I'd like to create a CPPUnit project to which I'd like to automatically add the CPPUnit library. For the life of me, I can't figure out how to achieve this end. Does anyone know how?
推荐答案
对不起我迟到了,但是对于同样的问题我也有同样的问题。我已经找出了一个解决方案。它适用于我,但我很清楚,它可能不像希望那样普遍。在您的template.xml中,您可能需要添加以下过程:
Sorry I am late, but I just had the very same question for the very same problem. I have figured out a solution. It works for me, but I am well aware that it is probably not as general as hoped for. In your template.xml, you may want to add the following process:
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues">
<simple name="projectName" value= "$(projectName)"/>
<complex-array name="resourcePaths">
<element>
<simple name="id" value="gnu.cpp.link.option.libs" />
<simple-array name="values">
<element value="dl" />
<element value="cppunit" />
</simple-array>
<simple name="path" value="" />
</element>
</complex-array>
</process>
关键部分是知道将两个库放在哪里 dl
和
cppunit
。关键 gnu.cpp.link.option.libs
是GNU编译器工具链中正确的一种,在大多数Linux计算机上都是活动的。
The crucial part is to know where to put the two libraries dl
and cppunit
. The key gnu.cpp.link.option.libs
is the correct one for the GNU compiler tool chain which is active on most Linux computers.
我从Eclipse插件 org.eclipse.cdt.managedbuilder.gnu.ui_XXXXXXX
中提取了密钥名称。您可以在Eclipse的插件
文件夹中找到它。如果您需要另一个工具集的密钥,我建议打开plugin.xml文件。在这里,您应该搜索属性 valueType =libs
。相应的 id
是您需要在流程文件中操作的关键。
I have extracted the key name from the Eclipse plugin org.eclipse.cdt.managedbuilder.gnu.ui_XXXXXXX
. You can find it at Eclipse's plugins
folder. If you need the key for another toolset, I recommend opening the plugin.xml file. Here, you should search for the attribute valueType="libs"
. The corresponding id
is the key you need to manipulate in your process file.
如果您还需要操作库搜索路径,请搜索 valueType =libPaths
。这将导致您关键 gnu.cpp.link.option.paths
。您可以使用与上述相似的过程向列表中添加其他条目。
If you also need to manipulate the library search path, search for valueType="libPaths"
. This will lead you to the key gnu.cpp.link.option.paths
. You can add additional entries to the list with a process similar to the one shown above.
这篇关于Eclipse CDT新建项目模板 - 如何添加库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!