Search code examples
visual-studio-codegccmingw

I'm not able to use my C/C++ compiler on vscode


I followed the gcc compiler installation tutorial for windows from the vscode website: https://code.visualstudio.com/docs/cpp/config-mingw

And the bin folder (C:\msys64\mingw64\bin) is empty, so i'm not able to run the "g++ --version" by adding this path to the Windows path environment variable.

My alternative to it was to use the codeblocks compiler to run my code in vscode, by adding this path: (C:\Program Files\CodeBlocks\MinGW\bin) to the "path" selection in the windows environment variables.

I want to make the MSYS2 compiler work properly in my vscode.

Hope you guys can help me!


Solution

  • MSYS2 comes with a package manager pacman that you should use to install any components you need.

    In your case, open the MSYS2 shell (by running mingw64.exe) and run the following commands:

    pacman -Syu --noconfirm 
    pacman -S mingw-w64-x86_64-toolchain
    

    The first command will tell the package manager to update it's database, the second command will get the MinGW-w64 64-bit GCC compiler.

    If you don't really need MSYS2 (e.g. because you dan't plan to use the MSYS2 shell) you could also consider getting a standalone MinGW-w64 build from https://winlibs.com/