How to setup visual studio for cross platform c++ development How to setup visual studio for cross platform c++ development unix unix

How to setup visual studio for cross platform c++ development


First of all, select a non-managed C++ project (to avoid the .net stuff).

After that, turn up the warning level (/W3 should do), and be very careful what you do/write. IMHO, GCC is better at keeping you straight with the standard (-Wall -Wextra -pedantic -std=c++11), but you specify MSVC.

As Noah said, you'll need build system that is in itself cross-platform, like CMake (there are others, please don't forget that).

Remember to use platform/architecture/compiler independent types, like std::size_t, std::(u)intptr_t etc. instead of plain int, long, unsigned: these are a recipe for disaster and the Windows API throws these around way too much.

See here, but only/especially points 1, 2, 5, and 8 (and 9, but generalize that to svn, git, mercurial).


I'm especially curious on how you make sure that things like the project file stay in sync with the make files which are probably needed on the *nix platforms.

Since MS decided to remove support for makefiles from VS, you don't. You use something else that can generate VS project files and make sure you keep THAT set up correctly. Something like CMake.


This is an ancient question from 6 years ago, but I'd just like to point out that Microsoft now has official tools to work with linux c++ in Visual Studio:

https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/

In addition, Windows 10 now has abilities to run Linux inside Windows, so it should make your life a lot easier for anyone still interested in developing in C++ for Linux on Visual Studio.