At the moment this is very hard in C++. Some people have said it is impossible which is not correct but it requires very deep knowledge of what is the same and what is different between Windows and Linux and Android etc.
I have been working on this exact issue and have solved many of the problems over 10 years but the solution is not yet complete. If you search for my article
"Introduction to the QOR"
on Code Project articles or for
on SourceForge you will find what I have published so far which includes a very small test program that will build and run on Windows and Linux with seven different compiler/IDE combinations. Almost all of this except for the projects to build under other IDEs was written in Visual Studio. Building on one system for another kind of system is called cross-compiling. Visual Studio cannot do this for Linux so I build on Linux for Linux and for Windows on Windows but the code is the same and comes from a shared network drive.
In the near future it will be possible to build one application in just C++ and build and run it on Linux, Windows, Android, OSX in 32bit and 64bit versions, with the compiler of your choice and if you want to write all the code in Visual Studio you can. This is the dream and I know how to achieve it but I only have 10 fingers and 24 hours in the day.
For now you could look at Java or Mono but if C++ is your thing then road is harder but the end is better.