简体   繁体   English

使用 VisualStudio 进行跨平台 C++ 开发

[英]Cross-Platform C++ development with VisualStudio

I want to start a cross-platform C++ project with VisualStudio 2019. After some research I found two possible ways:我想用 VisualStudio 2019 启动一个跨平台的 C++ 项目。经过一番研究,我发现了两种可能的方法:

CMake CMake

Tutorial: Create C++ cross-platform projects in Visual Studio 教程:在 Visual Studio 中创建 C++ 跨平台项目

Create and configure a Linux CMake project 创建并配置 Linux CMake 项目

CMake is pretty common for cross-platform projects, but I haven't done much with it and it feels like you need to put in much effort to make it run as you want to. CMake 对于跨平台项目来说是很常见的,但我并没有做太多,感觉需要付出很多努力才能让它按你的意愿运行。 But you have a huge amount of possibilities to configure it.但是您有大量的可能性来配置它。 This SO questions also recommends CMake, but says that there are other ways. 这个SO questions 还推荐 CMake,但说还有其他方法。

VS Shared Project VS 共享项目

Shared Project: An Impressive Feature of Visual Studio 2015 共享项目:Visual Studio 2015 的一个令人印象深刻的功能

Cross-platform code sharing with Visual C++ 与 Visual C++ 的跨平台代码共享

If you use cross-platform code sharing in VS you have several projects in your solution (one for each platform) and at least one shared project, which includes your source + header files.如果您在 VS 中使用跨平台代码共享,您的解决方案中有多个项目(每个平台一个)和至少一个共享项目,其中包括您的源 + header 文件。 The platform specific projects include all the configuration settings and the program entry point.平台特定项目包括所有配置设置和程序入口点。 The shared code can be used from each project as if it is in the project.可以从每个项目中使用共享代码,就好像它在项目中一样。 All the configuration is possible in VS.所有的配置都可以在 VS 中进行。 It looks less complex but with limited possibilities.它看起来不那么复杂,但可能性有限。

Question问题

Both ways look like they would fit my needs, but I haven't found a comparison between them.两种方式看起来都适合我的需求,但我还没有找到它们之间的比较。 I already coded running examples for both of them, but those small code bases haven't given me the insight I need.我已经为它们编写了运行示例,但是那些小的代码库并没有给我我需要的洞察力。

What are the pro's and con's of those two ways?这两种方式的优缺点是什么? Considering attributes like build-speed, flexibility, time to learn/master/market, VS feature support, unit testing, continuous integration, ...考虑构建速度、灵活性、学习/掌握/市场的时间、VS 功能支持、单元测试、持续集成等属性...

Take a look at Premake .看看Premake You can generate Makefiles and VS project from simple lua configurations.您可以从简单的 lua 配置生成 Makefile 和 VS 项目。 Not a lot of projects use premake but my experience so far has been positive.没有很多项目使用预制,但到目前为止我的经验是积极的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM