How to use GCC compiler in Visual Studio

This seems like it should be easy to do but after a couple hours of Googling I still can't figure out how to use GCC as the compiler for C++ in Visual Studio. I've installed MinGW and the the gcc packages from the installation manager and set the PATH variable to include "C:\MinGW\bin".

According to I can go to Project -> General -> Platform Toolset and select the compiler from there. The only options are Visual Studio 2019 (v142) and Visual Studio 2017 (v141) - I don't see the GCC compiler. I'm required to use GCC as the compiler for this course so any help with setting the compiler to be GCC is much appreciated!

3

1 Answer

After a couple of hours I found out how one can change the compiler in the Visual Studio. However, it is not quite what you need. Anyway it is better than nothing.

  1. Open the Visual Studio Installer, click on the "Modify" button un make sure that you have the following components installed: Desktop development with C++, Linux development with C++.
  2. Open the Visual Studio, click on the "Create a new project" and choose for the language "C++", for the platform "Linux". Then you will see all available projects:enter image description here
  3. I choose the "Console Application" project for Linux. Than, click on the "ConsoleApplication1" in the project explorer with the right mouse button, than on "Properties" and you will see this window:enter image description here

I think, it is exactly what was written here. But for this solution you need a Linux machine that you can connect to and then compile on (Visual Studio explains exactly how this works when you create a project).

As an alternative, I could explain how to compile C and C ++ files under Windows in VS Code, but that's certainly another question.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like