Eclipse CDT:如何在单个C ++项目中管理多个main()函数? [英] Eclipse CDT : How to manage multiple main() functions in a single C++ project?
问题描述
我希望避免为每个测试平台及其main()函数使用一个Eclipse项目。
我阅读了关于工作集和仅在我的项目中显示特定测试平台的文件的想法是我搜索的。
然而,在构建阶段,Eclipse继续构建所有的项目文件,而不是当前的工作集文件。我有一个链接器错误,因为多个main()函数。
如何配置Eclipse来构建工作集的文件?
是否有另一种方法在单个项目中单独构建多个程序,即应用程序及其组件testbenches?
可以通过写入自定义的 makefile 。例如,它是处理主要应用程序及其组件测试脚本的C / C ++项目的一个潜在解决方案。
请参阅这里如何在Eclipse中指定自定义makefile。
然后定义一个主要规则(见 makefile 文档)构建整个应用程序(无需测试脚本),并为每个要构建的测试脚本(及其组件)定义一个附加规则。
总结:在您的makefile中定义一个规则主要功能,构建主要及其依赖。
I am starting the developpement of a project which will be made of multiple modules. I will validate each of those modules with a dedicated testbench, each with their main() function.
I would like to avoid having one Eclipse project for each testbench and its main() function.
I read about Working Sets and the idea of showing only the files concerned for a particular testbench in my project is what I search for.
However, during the build phase, Eclipse continues building all the project files, not the current Working Set files only. I then have a Linker error because of multiple main() functions.
How can I configure Eclipse to Build the files of a Working Set only?
Is there another way to build multiple programs separately in a single project, i.e. an application and its components testbenches?
It is possible to deal with multiple main functions in Eclipse CDT by writting a custom makefile. It is a potential solution for C/C++ projects dealing with a main application and its components testbenches, for instance.
See here how to specify a custom makefile in Eclipse.
Then, define a main rule (see makefile documentation) building your whole application (without the testbenches) and define one additional rule for each of your testbenches (with its component) to be built.
To summarize : define one rule in your makefile for each of your main function, building the main and its dependencies.
这篇关于Eclipse CDT:如何在单个C ++项目中管理多个main()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!