Reputation: 41
I cannot for the life of me figure out how to run and debug a c++ file in vscode. There are always at least one or two things wrong.
I've already used the basic tutorials, but they don't seem to work for me.
Can someone explain it to me like I am 5 years old? Or point me in the direction of a place that will? I am totally burnt out and feel like a total dunce. I can't get a hello world program running and it is driving me crazy. Any help would be appreciated.
Upvotes: 1
Views: 157
Reputation: 587
c++
compiler I prefer mingw
.ctrl + shift + x
.ctrl + ,
By GUI
Code-runner: Run In Terminal
will be unticked by default. You tick it and close settings tab. Refer the pic for better understanding.Terminal
and select Run Build Task
then click ctrl + alt + n
to run the code. Again refer image for better understanding.This should work, but if still didn't work let me know. Else refer any youtube video , you might have committed small mistake. Let me know if this didn't work my dear 5 years old guy ;)
Upvotes: 0
Reputation: 11
Is it on Windows or Linux ? If on windows, first download and install the mingw setup. You can find it here : https://sourceforge.net/projects/mingw/ After installation, add the location of th bin of g++ to PATH so that you can access it via the command line. You can also add some extensions to your VS Code to make debugging C++ code easier, then in VS Code, open the terminal, and , while in the directory where you have your cpp file, simply do a g++ filename.cpp to compile, then run the executable, a.exe, unless otherwise specified in the previous command . Hope this helps
Upvotes: 1