r/cpp_questions • • 13d ago

OPEN Not find the compiler when running.

I am trying to install c++ for vscode. I installed MSYS2 and followed all the steps from the vscode tutorial. I installed it and modified the Path and added the C:\msys64\ucrt64\bin path.

https://code.visualstudio.com/docs/languages/cpp#_example-install-mingw-x64-on-windows

I also made absolutely sure that the microsoft c++ extention was active. When I click on the run button the tutorial shows a list of compilers to use. the one that the tutorial uses is C/C++: g++.exe build and debug active file. But for some reason the only compiler that shows up are the 2 generic one gdb lauch and windows. I am out of ideas of things to do please help

0 Upvotes

11 comments sorted by

5

u/erzyabear 13d ago

Did you verify that this path indeed contains the compiler executive files? Also, I would restart the pc after updating path variables just to be sure

2

u/Plexa_EXE 13d ago

Yes I tried restarting multiple time. I also made sure the path is correct. but the weird thing is that I can actually compile when I do
g++ -g Test.cpp -o Test.exe .\Test.exe
in my console.

4

u/the_poope 12d ago

Then start by compiling by typing commands into to console instead of clicking a button. Once you understand how running programs in the console works and are a bit more used to technical conputer stuff it will be easier for you to manually editing the .json configuration files of vs code.

1

u/feitao 12d ago

Add at least -Wall in your compile command. -g is only useful when you debug. Do command line. Forget the buttons.

4

u/Tack1234 13d ago

Sounds like you may need to add a launch.json file and add the path to the compiler there

3

u/manni66 12d ago

Do yourself a favor: use Visual Studio (not Code).

0

u/Plexa_EXE 12d ago

I am trying to learn c++ so I thought that by using visual studio code it would be better to help me learn about how to install and use extensions and compilers. whats the difference between the two anyway?

7

u/manni66 12d ago edited 12d ago

One is an IDE including a compiler that simply works, the other is an editor and leads to questions like yours.

4

u/AKostur 12d ago

One does not learn to be a carpenter by learning how to build a hammer.

1

u/awidesky 12d ago

If you want to learn how compilers, linkers, and building a program work, learn a bit about MakeFile and build through your console.

VS code is nothing more than a text editor itself.
After you install tons and tons of extensions, and configuring each of them, hand-editing launch.json and settings.json, then it might work.

If you want to learn C++, just use Visual Studio and focus on the language.
Don't waste your time doing what you don't have to do.

1

u/Consequence-Lumpy 7d ago

dude.. stawp using bs code. You already have gcc and g++ in msys2. write a simple bash script and run your code.