Skip to content
Advertisement

Compiling my C++ exe for Linux with VS2019

I have created a C++ standalone exe with VS2019. This exe uses 1 external ressource file. This exe creates WAV files.

It does not use any special libraries.

I have been asked if this application runs under Linux, too.

What would I have to do / check to see if / how I can compile my application for Linux, and would that be possible using VS2019?

Thank you very much for the help.

ps: Here is a screenshot of the properties of my project: ros

Advertisement

Answer

Usually to build C++ applications for Linux, you must first use a compiler that will build for the target OS. In this case VS2019 (and it’s associated compiler) builds executables for Windows only.

If you’re trying to target Linux, you have two options:

  1. You can move over to a Linux system and build your project with the GNU c++ compiler (I recommend using CMAKE to build your project since it’s not tied to any particular IDE and can generate makefiles for gcc). https://cmake.org/cmake-tutorial/

  2. You can install the Windows Subsystem for Linux (WSL) and do a remote build with VS2019. You’ll see more and more of this these days in production environments. https://devblogs.microsoft.com/cppblog/linux-development-with-c-in-visual-studio-2019-wsl-asan-for-linux-separation-of-build-and-debug/

Hope this helps!

Advertisement