How to set up Visual Studio Code for Executing and Debugging C++ Programs | Tutorial for Beginners
In this tutorial, you will learn How to Set up Visual Studio Code for Creating, Executing and Debugging C++ Programs.
00:00 Introduction
00:36 Check g++ and gdb are installed
01:44 Set up Visual Studio Code Work Space
04:58 Installing C/C++ Extension in VS Code
06:17 Configure C/C++ Properties
08:18 Set up Build Task and Run Program
13:27 Configure Task to Build and Run Executable File
24:04 Set up Vs code for debugging
26:46 Debug Cpp Program using a Break Point
Visual Studio Code is the widely used editor in Computer Programming field.
It is the best editor for a beginner in programming because it is simple, easy to set up and has all those features needed.
First you need to Download and Install C Cpp toolset ( Compiler , linker etc ) like mingw-w64. After that you need to install Visual Studio Code.
Download and Install gcc using Mingw-w64 and msys2
• How to Download and In...
Download and Install Visual Studio Code
• How to Download and In...
Our Website
www.LearningLad.com
Social Media
Facebook / learninglad
Twitter / learningladedu
Instagram / learningladofficial
Пікірлер: 416
I'm just in love with this video man!! It was so great! You explained the entire process right from the basics and it was just too good to be expressed in words. 15/10 for this one.🔥🔥🔥🔥🔥
@LearningLad
3 жыл бұрын
Glad you liked it!
@quirkyquark99
2 жыл бұрын
@@LearningLad Sir, when I click "Run and Debug" it says, FAILED TO PARSE JSON FILE, POSSIBLY DUE TO COMMENTS OR TRAILING COMMAS. Please help.
At first, the program in the VS Code terminal did not start for me (initially, the "Powershell" terminal was selected). Then I selected the "Command Prompt" terminal (the "Launch Profile" button next to the "New Terminal" icon at the bottom right of the screen, then select "Select Default Profile" and in the drop-down list - "Command Prompt"). After that everything worked. Many thanks to the author for the detailed instructions and the work done!
@LearningLad
Жыл бұрын
thank you for posting. it will help others :)
@overclockinggames2419
Жыл бұрын
Thanks for this comment, it helped me a lot
@bhupendranagda9563
Жыл бұрын
Dude a huge thanks to you
@shairamei24
Жыл бұрын
Thank you 🖤
@priyatiwari22
9 ай бұрын
Thank u ur comment really helped me ...I was too suffering same problem 😊
Thank you very much!!! Way simpler and better explained than the VSCode web page.
This is amazing! Always wanted to know a way to debug programs while writing programs for competitive questions! Finally, I can use a debugger of my own! :D
@LearningLad
2 жыл бұрын
Awesome 👏
Thank you so much! After watching many tutorials and getting stuck on how to set up the debugger, this video helped me successfully run the debugger!
@LearningLad
2 жыл бұрын
Awesome
@WangzGamez
Жыл бұрын
I was wondering why when I ran, "Hello World.exe" in the terminal it was just displaying it as a string array. Thanks!
Thank you very much, sir. You've made my day! I couldn't get it to work, and googled unsuccessfully for quite some time, until I found your video.
@LearningLad
Жыл бұрын
You are welcome!
I had problems with setting this shit up since last 6 freakin' hours until I found your channel. You're my hero
Excellent tutorial! I've spent the last 5 hours using this video along with the one about installing MinGW-w64 and Msys2 to finally get my debugger to run. Learnt a lot in the process. Thanks a mil!
@LearningLad
2 жыл бұрын
You're welcome!
Excellent explanation - found I could follow along with each step. You have a very effective style - thank you
@LearningLad
2 жыл бұрын
welcome :)
only this video has worked for me, for configuring debugging option in my vs code.. just because of this i had shifted to lazyvim... now it feels happy to be back again
@LearningLad
3 ай бұрын
Glad it helped
This is, most probably the best video for VS Code Configurations setup. I learnt so much and got curious about tasks.json and launch.json, that I learnt how to write configurations by myself. Now I do it my way, thanks Sir for this tutorial which was the stepping stone.
@LearningLad
5 ай бұрын
Glad it was helpful!
So helpful! I am taking CS50 and needed to get C working on VSCode. This worked!
@LearningLad
3 ай бұрын
Glad it helped!
your video teaches me many things that I can't learn from the books or lecture. It provides all things to get start without tedious google. Thanks alot.
@LearningLad
3 жыл бұрын
Pleasure
@yogesh2395
2 жыл бұрын
@@LearningLad Sir can you please make such video for Java also, like launch Json and other stuffs related to build and run java programs in Vs Code
Thank you so much for this video. It is highly valuable. It teaches professional C++ software development environment setup (MinGW64 toolchain via MSYS2 and VS Code) in a right way. We are thankful to get educator like you. God bless you!
@LearningLad
Жыл бұрын
You're very welcome!
Thank you so much! This video solved my debugging problem which was lasting for long time.
@LearningLad
Жыл бұрын
Glad it helped!
oh my god, i can't believe i found this video this is literally what i've been searching for months.
Wow, something so simple like learning about the Command Palette (what an obfuscating name, should be like "Search Commands" or something) pretty much solved my doubts. Thanks!
@LearningLad
2 жыл бұрын
Glad it was helpful!
Thanks, Anil! This is just what I wanted!
@LearningLad
2 жыл бұрын
Pleasure
Microsoft has such a great product in VSCode but I’ve always found their tutorials lacking when it comes to personalizing your environment. I learned more from this video than from anywhere else. Keep up the good work!
@LearningLad
2 жыл бұрын
Thanks :)
@sarthaksachdev197
Жыл бұрын
@@LearningLad hey mine is not working its showing a completely different error after doing 17 minutes of this video
sir , I am getting a error " The Token '&&' is not a valid statement seperator in this version." And my output during the build task also isn't showing " number is : 30 good Bye ! " Please help me
@asha501
4 ай бұрын
I am also getting the same error
I thank you for your time and effort into making this video. This is an excellent video. Well thought out and the sequence of presentation is very good.
@LearningLad
5 ай бұрын
Glad it was helpful!
Thank you for your indepth tutorial. It really helped me a lot.
@LearningLad
2 жыл бұрын
Pleasure
Your instructions are very clear. Thanks for your video. I have subscribed to the channel. By the way, I wish India a speedy end to the covid epidemic. Love from Vietnam ❤❤❤
@LearningLad
2 жыл бұрын
Thank you :)
Its working dude, amazing!
@LearningLad
3 жыл бұрын
Glad to hear that
GREAT!!! WORKED PERFECTLY
@LearningLad
3 жыл бұрын
Pleasure
Thank you my friend, very helpful tutorial!
@LearningLad
2 жыл бұрын
Pleasure
Thank you so much for this fantastic tutorial! subscribed and shared :)
@LearningLad
2 жыл бұрын
Pleasure
Thank you for this tutorial. this is very helpful.
thanks a lot bro. this video is really helpful.
@LearningLad
2 жыл бұрын
You are most welcome
most accurate tutorial for anything ive ever seen
@LearningLad
Жыл бұрын
thank you :)
loved this video thanks for a lot of help.
@LearningLad
3 жыл бұрын
You're welcome!
Outstanding tutorial! This video really helped me get started. The presentation is very clear and explains very clearly how to run and debug a simple first program. Thank you so much.
@LearningLad
3 жыл бұрын
Glad it helped!
Very well explained Sir Thank You!
@LearningLad
3 жыл бұрын
Most welcome!
Thank you, very helpful video!!
@LearningLad
Жыл бұрын
Glad it was helpful!
Thank you! very useful!
@LearningLad
2 жыл бұрын
pleasure :)
thanks for the great explanation
@LearningLad
Жыл бұрын
Pleasure 😊
Very Useful !
@LearningLad
2 жыл бұрын
Glad you think so!
I really thanks for your helping, it's save my time :') I really appreciate it.
Nice. Can you do a video using cmake & make setting up the correct folder structure for a project while linking to any external header files?
I appreciate your job, thank you. Can you make a video Executing and Debugging C++ Programs with C++ Build Tools for VSCODE, many of us have the same problem!! Nice job, thanks a lot
LOVE THE PROGRAM
i am getting the following error, can you help me with this "the token '&&' is not a valid statement separator in this version"
@s.shirani1244
4 ай бұрын
try replacing && with ;
@asha501
4 ай бұрын
I am getting the same error
wow, the presentation so clear and smooth, Great help in understanding the processess. What softwares were used in making this video.
Great Info!
@LearningLad
3 жыл бұрын
thanks
thanks So much, it's really useful ❤️🔥🔥🔥
@LearningLad
2 жыл бұрын
Pleasure
Bundle of Thanks :)
@LearningLad
2 жыл бұрын
pleasure :)
Thanks a lot!
Fantastic Walkthrough mate!! Would you be able to make a series of tutorials for WINAPI debugging ?
@LearningLad
2 жыл бұрын
I will try
Very helpfull thanks a lot!!!!!!!!!!!!!!!!
@LearningLad
Жыл бұрын
You're welcome!
thanks a lot bro it helped me :)
@LearningLad
3 жыл бұрын
Glad it helped
thank u so much
@LearningLad
2 жыл бұрын
You are most welcome
Thanks a lot ! 😊
@LearningLad
Жыл бұрын
You're welcome 😊
NO ONE DOES IT BETTER! thx learningLad
Thanks a lot bro
@LearningLad
2 жыл бұрын
Always welcome
thanks a lot you really help me
@LearningLad
8 ай бұрын
You are most welcome
thank you very much
@LearningLad
3 жыл бұрын
Pleasure :)
thank you bro👍👍
@LearningLad
Жыл бұрын
Welcome 👍
excellent!
@LearningLad
3 жыл бұрын
Thanks!
Great video
@LearningLad
2 жыл бұрын
Thank you
Thank you
@LearningLad
8 ай бұрын
You're welcome
tank you my frient one more time!
@LearningLad
2 жыл бұрын
Always welcome
I have getting an error saying that token '&&' is not a valid statement seperator in this version Please respond
thank yo so much
@LearningLad
15 күн бұрын
You're welcome!
'C:/Program' is not recognized as an internal or external command, operable program or batch file. The terminal process "C:\WINDOWS\System32\cmd.exe /d /c "C:/Program Files/mingw64/bin/g++.exe" -g3 -Wall "e:\code blocks Projects\C++ Programs\factorial.cpp" -o "e:\code blocks Projects\C++ Programs\factorial.exe" &&"e:\code blocks Projects\C++ Programs\factorial.exe"" terminated with exit code: 1. how to solve it sir.
@user-gw4ph2us5q
2 жыл бұрын
Same here. What was the solution ?
@khoinguyentran8734
Жыл бұрын
@@user-gw4ph2us5q have you fixed this yet sir?
Great!
@LearningLad
Жыл бұрын
thanks
Hello sir! If we have two or more cpp files in our project, which is the configuration of json file? Thank you!
I thought it would have been a little less difficult to get my VS code and c++ Work Space set up. I'm very grateful for you. But if I was on my own doing that there is no way. The compiler integration was very rough but how is anyone able to understand what's going on. I guess I do need to go learn some C.
I have a question with this i could Executing a more programs in the same folder? , for example if i want to make a big project and separated in differents headears and cpp files and include them in my main.cpp, thank you
Sir can you please make such video for Java also, like launch Json and other stuffs related to build and run java programs in Vs Code
Do you have any video on how to build and debug c++ projects with multiple cpp files and headers?
thanks
@LearningLad
2 жыл бұрын
Welcome
Hello In the part named "Set up Build Task and Run Program" it doesnt work for me there is no any output.Can anyone help me? Thanks.
شكرا
Brother, I am getting error after adding double quotes and backslash. I have checked double checked everything while typing. Should I change "cwd" to bin of Mingw because its showing ${fileDirname} on my pc.
That Debugging Part, you explained it in a nutshell __/\__
module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained,,, I have this error. what should I do?
Suppose I don't have the .cpp source file but only the binary "a.out", which is already running. Is there a way for me to monitor the variables and expressions after attaching the debugger to the a.out process?
Hi, I want to run a cpp program on external console and at the same time debug the program, is that posible? I tried configurate that but I don't find a solution.
Thank you very much, finally i can use debug on my visual code
@LearningLad
Жыл бұрын
You are welcome!
The half part of Video with "Hello World" is working correct on my PC but the 2nd , NOT, even I exactly followed the paradigm ? It seems compiler can't find the path to "Hello World".cpp to build executable program? Do someone met same problem,please? Athens,Greece.
Very great video keep up your work !!! I don't why my "Run C++ Program: g++" task taking forever to starting build !!! 😑
Sir,when i try to debug, it says," launch: program ' directory/debug/outdebug' does not exist. ", how to solve this problem?
@DiceKnight
2 жыл бұрын
Did you ever figure it out?
@sushilmhetre8625
2 жыл бұрын
Did you get any solution? 🤯 Stuck with this for so long now!
@sushilmhetre8625
2 жыл бұрын
@@DiceKnight ??
@sunny1005086
2 жыл бұрын
@@DiceKnight I am sorry for replying late, actually I stopped coding in C++ long time ago as nowadays I mostly code in python, js, html and use pycharm for my work. It was fun solving problems in C++. As far as I remember, I fixed this problem but I forgot how. :(
@Govt_and_tech
2 жыл бұрын
How to solve it bro..?
I am getting this instead of the output upon running. > Executing task in folder projects: C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\g++.exe -g3 -Wall"c:\Users\Shambhvi's pc\Documents\projects\Hello World\Hello world.cpp" -o "c:\Users\Shambhvi's pc\Documents\projects\Hello World\Hello world.exe" |"c:\Users\Shambhvi's pc\Documents\projects\Hello World\Hello world.exe" The string is missing the terminator: '. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString The terminal process "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\g++.exe -g3 -Wall"c:\Users\Shambhvi's pc\Documents\projects\Hello World\Hello world.cpp" -o "c:\Users\Shambhvi's pc\Documents\projects\Hello World\Hello world.exe" |"c:\Users\Shambhvi's pc\Documents\projects\Hello World\Hello world.exe"" terminated with exit code: 1. Terminal will be reused by tasks, press any key to close it. Please help me. @LearningLad
I got to the point where you use the Run and Debug button and the drop down comes up, but when I click the GDB selection it just disappears with nothing happening, help?
@Game666God
2 жыл бұрын
I found out that the Run and Debug button isn't creating the launch.json file so I copied the one you had up and it still didn't work
@nunusvenus7945
2 жыл бұрын
same here
how to disable the auto create of .exe file and disable the complete path in the output window.
Bro its showing '&&' is not valid statement separator in this version.....help plzz
i dont get option to add tasks.json C:\msys64\mingw64\bin\g++.exe this isnt shown in my suggestions, but it is installed i checked from cmd
sir in the debugging part, while selecting configuration, i selected default configuration by mistake, how should i change it now? my debugging doesnt work.
Hi, how to take input in debug mode??
After doing "13:27 Configure Task to Build and Run Executable File" this part vs code ....... "The token '&&' is not a valid statement separator in this version." .............plz help me.............
@ItachiUchiha-mn9di
2 жыл бұрын
same with me. did u fix it?
@davidroberts5751
2 жыл бұрын
@@ItachiUchiha-mn9di try ";" instead of "&&"
Please, I need help. I did everything exactly as stated but my vs code constantly highlights my "include " statement which makes my program not run. I love your video and I followed everything so Idk why mine's not working.
no need to do 13:28 (for me only) Run in terminal video (watch) For debugging we have to use debugger symbol on the top right corner
@LearningLad
Жыл бұрын
thanks for sharing :)
im not getting cout line and cin line while debugging, could you please help me in that
At line:1 char:184 + ... hil\Desktop\vs c++\programmimg\hello world\hello world.exe &&c:\Users ... + ~~ The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine what is the solution for this?
@user-gw4ph2us5q
2 жыл бұрын
Same here. What was the solution ?
@nunusvenus7945
2 жыл бұрын
same here
@davidroberts5751
2 жыл бұрын
@@nunusvenus7945 use ";" instead of "&&"
How can I include header files that are being used by my .cpp in task.json?
How to include path for end1,because it showing error when run task
The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsE rrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine this error is showing after tasks.json setting . i dont know what to do for run and execute at one time in powershell now
@creativeroyal_
Жыл бұрын
same brother , have you solved it???
HelloWorld.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher. How to fix them guys?
please help me with this, I have installed a new version of vs code but when I copied your program it says && cannot be used as a separator and cc1plus.exe: fatal error: World.cpp: No such file or directory I really want to learn, please reply!
@LearningLad
Жыл бұрын
go through the comment section. many have advised to use ; and some other character instead of &&
when i write "hello world.exe"it just writes back hello world.exe and dosents open the file what to do