VisualStudio中有多个主要CPP文件? [英] Multiple main CPP files in VisualStudio?

查看:663
本文介绍了VisualStudio中有多个主要CPP文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些软件的示例目录,其中包含具有多个main功能的多个文件.我可以将所有这些文件组装到单个项目中,对其进行编译,然后运行特定文件而不会出现main already defined错误吗?假设我不想为每个cpp文件创建单独的项目.

I have a sample directory of some software, which contains multiple files with multiple main functions. May I assemble all of these files into single project, compile them and then run specific ones without getting main already defined error? Suppose I don't want to create separate project for each cpp file.

更新

我需要一个简单的一键单击两次解决方案(如果存在).我不想在文件夹之间分发文件或重构文件内容.例如,在Eclipse/Java中,您可以右键单击任何带有main的文件并运行它.一个项目中可以有许多主要文件.对于VisualStudio/CPP,这可能吗?

I need simple one-two-click solution (if it exists). I don't want to distribute files among folders or refactor files content. For example in Eclipse/Java you can right-click any file with main and run it. And there can be many of main files in one project. Is this possible for VisualStudio/CPP?

更新2

我知道C ++不是Java,而Visual Studio不是Eclipse.我的问题是关于一些手动操作的自动化.

I know that C++ is not Java and that Visual Studio is not Eclipse. My question is about automation of some manual operations.

推荐答案

我尚未使用OpenCV,但它使用cmake,并且在示例目录中具有CMakeLists.txt.在此处.

I haven't worked OpenCV, but it uses cmake, and has a CMakeLists.txt in the sample directory. There's some discussion about building the samples using cmake here.

Cmake本身不会构建任何东西,它会为目标平台生成构建脚本,并且应该能够创建可以加载到Visual Studio中的解决方案和项目文件.

Cmake doesn't build anything itself, it generates build scripts for the target platform, and should be able to create Solution and Project files that you can load into Visual Studio.

这篇关于VisualStudio中有多个主要CPP文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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