Eclipse CDT:如何在单个C ++项目中管理多个main()函数? [英] Eclipse CDT : How to manage multiple main() functions in a single C++ project?

查看:492
本文介绍了Eclipse CDT:如何在单个C ++项目中管理多个main()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始开发一个由多个模块组成的项目。我将使用专用的测试平台验证每个模块,每个模块都具有main()函数。

我希望避免为每个测试平台及其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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆