首页 > 解决方案 > How to compile C++ for Mac OS X using Visual Studio on Windows and CMake

问题描述

I read that Visual Studio now supports cross-platform development. I'm using CMake to compile for Windows and Ubuntu (using WSL) so far. However there doesn't seem to be any information on how to actually accomplish the cross-compilation using Visual Studio to target Mac OS X. Is it doable with the CMakeSettings.json? According to this article, you can choose Linux-Debug and Linux-Release as configurationType but in Visual Studio 2017 Enterprise the Linux options aren't even available for me, neither is Mac OS X.

I might just setup a virtual machine as suggested in this post which seems to be the most convenient solution to get the job done.

标签: c++macosvisual-studiocmakecross-compiling

解决方案


显然你不能。

我最终安装了一个虚拟机,Mac OS X并使用共享文件夹成功地在其中编译了我的代码,以使我的Windows主机源代码可供来宾使用。这肯定比一些 hacky 交叉编译项目更可靠、更理智。后者仍然不能保证代码能够成功运行并且不会在交叉编译目标操作系统上意外崩溃。


推荐阅读