 What's up guys? So today I'm going to show you how to set up Visual Studio Code with C++. So what I have here is I have main.cpp and I'm going to show you how to, by the end of this video, you should be able to both compile it and run it and debug it just from Visual Studio. So let's get started. Go to your extensions and make sure you download the Microsoft extensions back. And this VS Code directory has these files. It has settings to JSON, it has launch JSON, it has cppproperies.json. Don't worry about this and don't worry about the settings. What we're going to be focusing on is going to be launch.json. Now what launch.json does is it allows you to launch your programs and debug them. But before we can do that, we also need to compile our programs and to compile our programs what we're going to do is going to go to main.cpp and we're going to go to terminal and we're going to go to run build task. We're going to click here. And what we're going to get is we're going to get a bunch of default build tasks we can run. So what are these build tasks? Well, we have one for Clang, we have one for cppp, we have one for g++ and we have one for gcc. So depending on your compiler, just pick one of these build tasks. It doesn't really matter for now, just pick a compiler that you use. So I'm using g++ and because of that I'm going to go over here, don't click on this. What you're going to do is going to go to this configure tasks button and when you click this, it's going to create for you a task.json file. And what this task.json file is essentially going to do for you is it's going to tell the visual studio how you want to build your program. So let's take a look at what's in here. Okay, so tasks.json, what do we have here? Well, we have a label and this is the name of your task. So what you can do is you can just change this label to be anything you want. You can say my build task, that's perfectly fine. Name this my build task doesn't matter. Now the command. This is what visual studio is going to use to build your program. So what's going to happen is it's going to execute this command against the file. And in this example, what we have is we have this command. So this is the path to either a compiler or script that performs the compilation. So in my example, my g++ compiler is located in user bin g++. If on your computer, it does not exist in this directory, you will have to change this. Or if you don't have g++, choose the compiler that you're using. Or if you're using some build script, change this to point to the build script that you use. Now orcs, what are the orcs? Well, basically, what orcs are is the arguments to this command. And in this example, we're using g++. So what we're passing into g++ are the compiler arguments that you want to use. So for example, here's a familiar one, we have dash g. That just makes it easier to debug. This is built into visual studio. So dollar sign file. This is specific to visual studio. And let me just show you how this works. So if I click here, okay, so visual studio has a bunch of built in variables that you can use when you build and run your tasks or build and run your programs. And what we have here is we have basically a whole listing of them that have their descriptions CWD. This is the current working directory. That's pretty simple. We have a file base name, no extension, you are probably going to be using this a lot. And this is the file, this is the name of the file that you're building without extension. So if you want to, let's say, build a file that's called mean.cpp and you want to output it as just main, you probably will want to use this variable that is going to remove its extension. So if you want to build the main.cpp and remove the .cpp portion of it, you can just use main base name, no extension as the output. And in fact, in this example, that's exactly what this configuration is doing. So what we're doing is we're outputting this to this directory. And we are basically calling this main with no extension file base name, no extension. I think that should be pretty simple to understand. So what I'm doing to bring up this drop down menu is basically I'm clicking control and space. So basically just read through these variables. There are not that many of them. So whichever variables you need to use to get your build running, just use them and you should be fine. So in this example, I'm just going to use the default, I'm just going to say file, the way that this is now is perfectly fine. It's perfectly usable. So don't worry about this too much. So just save that, go back to main.cpp and then go to terminal and then click run build task. And let's see what we got. Okay, so it says executing task, my build task, starting to build. And as you can see, we basically ran g++ with these arguments. And then the output is going to home g vs code main. And if we look in our file browser, or if we look in this Explorer, we see that we created main, which is the executable. Now that we did that, let's go to run and then click start debugging. And we're getting an error. So let's try to fix this and see what the problem is. So in launch the JSON, we're going to go down and let's see, it says program full path to program executable. And as you can see, it's trying to execute in this directory build debug out debug. And we don't have this directory. So instead of this, so what we're going to do is going to replace this with our sign and then file, and we're going to use a file base name, no extension. Save this, go back to main.cpp, go to run and then click start debugging. And as you can see, we got hello world printback about 10 times. And that is exactly what this program is doing. Okay, so now what can we do with this. So basically what we can do is we can go in here and set breakpoints like this. And if we set a breakpoint and we click run, and then start debugging. What's going to happen is it's going to start this program and it's going to pause at this hello world, hello world statement. So if we click F10. So basically what's happening is we are just going through this program, and we're, we're just stepping through the execution, and the commands to debug this program are up here. So we have continue which just continues until the next breakpoint. So if I keep clicking continue just going to keep pausing at this breakpoint here. We have step over that's stepping over functions step into that's stepping into functions restart and we have stop. So these are pretty much very basic debugging tasks you can do. So this isn't a tutorial about debugging. This is a video explaining how to set up Visual Studio for for running your files. So pretty much that is basically all you need to know. So if you if you need a quick recap, what we have here is we have tasks.json. This is how you build your file. So go into tasks.json. So you build your file, go to launch. This is how we launch your file. And yeah, that's pretty much it. So, so let's stop this and let's do something differently. So let's change this to. Now to run this again, what we're going to do is going to go to terminal, I'm going to go to run build task, and I'm going to build this again. And then once that's finished, we're going to go to run and then start with debugging. And as you can see, if we go to our terminal, continue. So yeah, that's pretty much it. If you enjoyed this video, thank you. Make sure you give me a like and subscribe and I'll see you later.