How to set up C++ in Visual Studio Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there hope you're having a wonderful day in this video I'm going to show you how to set up C++ with Visual Studio code all right so for the first step you want to download a code editor so we are going to download visual studio code and to do so just go to code dovisual studio.com make sure it's the blue one not the purple one and over here just click download so I am using Windows so it says download for Windows but for you if you're using Mac it will say download for Mac so just click download and you will see this download page so your download should be processing do not exit this page because we will be using this for installing a C++ compiler so once you finish downloading the installer for visual studio code open that up accept the agreement click next create a desktop icon so you want to check this click next and then just click install all right so after you finish installing Visual Studio code let's install a C++ compiler so on the left hand side you'll see overview setup get started so just scroll down to where it says C++ click on this and click on the one for your operating system in my case I am using Windows so we are going to follow the instructions for installing GCC on Windows all right so now we have this page and we have prerequisites and one of them is install Visual Studio code so we have that done and there's an extension we need to install but we'll we do that later so first we want to install the MW tool chain so to do so we will install msis 2 and you can just click on this direct link to an installer all right after you've finished downloading the installer open it click next click next again click next again and then it will install m 2 all right so after that is done installing click finish and this will open up the msys2 shell and if you've accidentally closed it just go to search and look for msys2 okay all right so now what you want to do is go to this step four and just copy and paste this line and in Ms 2 right click and paste and hit enter so it says enter a selection just hit enter and then type y so yes proceed with installation all right so after the installation has completed exit the window and for the final step what we need to do is add mgw to the windows path environment variable so go to your search bar and type in environment variables and you want to click on edit the system environment variables so click on environment variables and then in user variables so this top one over here click on path and then click edit and we want to copy and paste this path so click on new paste it in hit enter and then click okay now if for some reason you do not have this path variable you can just click on new and type in path as the variable name and for the variable value you can just paste in that path for MW and then click okay all right so once you've added that to your environment variables just click okay and then click okay all right so the Moment of Truth we need to check our MW installation so search look for command prompt open that up type in GCC D- version and as you can see we have our compiler installed and let's also do g++ D- version and GDB d Dash version all right so it seems like we have everything properly installed so close this window all right so now what you want to do is open up your Visual Studio code and the first thing you need to do is click on this icon and we need to install an extension so type in C++ and click on this one so you want to install this c/c++ extension pack so this will provide all the tools you need for writing C++ code in Visual Studio code so click install all right so after you finish installing the extension pack close this and then click on this file icon let's create a C++ file so click file new text file and here in Visual Studio code we have an option to select a language so click on that and click on C++ and then let's save this file so you can save any anywhere I'm going to save it on my desktop so let's name this file test and as you can see over here it will save the file as a C++ file so click save and we have our first C++ file here and if you don't see that option for selecting a language just click file new text file again and just click control save and over here just type test.cpp so we are going to add an extension to signify that this is a c Plus+ file so the extension for that is CPP so click save and here we have our test. C++ so I'm going to quickly add some starter code all right so I have my starter code and if this is your first time writing C++ code I have a playlist teaching C++ on my channel and I'm going to have more videos on C++ in the future so I will link that in the video description but basically what it does is if I run this program it will just print hello world so to run the program we have this play button over here so in this drop down you can just click run c/ C++ file and then just click on the first one and if this is your first time running C++ on Visual Studio code you might see this stuff over here you can ignore it so just exit out and just run it again and as you can see we see hello world and I can also change this to Hello Kenny and then click save and run it again so we're compiling and now we're running the code and you can see it says hello Kenny all right so that's how you can set up C++ with Visual Studio code and if you found this tutorial helpful and it worked for you make sure you give this video a like And subscribe to the channel for more tutorials all right so that's it for this video and I'll see you in the next one bye-bye
Info
Channel: Kenny Yip Coding
Views: 254,973
Rating: undefined out of 5
Keywords: setup c++ visual studio code, setup c++ vscode, c++ vscode, install c++, how to setup c++ for visual studio code, visual studio code c++ setup, c++ vscode setup, setup c++ in vscode, setup c++ in visual studio code, setup c++ for visual studio code, run c++ in vscode, run c++ in visual studio code, run c++ vscode, run c++ visual studio code, how to run c++ in vscode, how to run c++ in visual studio code, vscode c++, c++ visual studio code, c++ setup, install c++ vscode
Id: DMWD7wfhgNY
Channel Id: undefined
Length: 6min 53sec (413 seconds)
Published: Fri Oct 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.