Setting up VSCode and Clang for C++ on macOS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay this is jim moroney recording the video for tennessee tech university for their cse 1300 course today i'm going to be showing you how to set up your computer for c plus plus programming and compiling uh if you're using mac os there's already a video out for the windows users if you need that but today we're just going to be going over mac os so at some point during your introduction lecture or skim through ilearn you should have found something that says getting your computer set up i don't exactly know where it is because i don't have access to your specific ilearn but somewhere in the content folder of your uh i learn materials you should find something like this yours will be a docx file but i've just converted this to pdf to make it a little bit more easy to scan through while i'm video so once you have that down and downloaded let's take a look at it and you might be you know tempted to just jump right into it jump right here and start following all these programs without reading too much usually that's what i do my you know monkey brain goes right to clicking on the pictures and stuff like that but if you do that you're going to be a little bit lost because mngw is a windows program that's not what we're looking for it's a uh open source compiler we're going to be using something that should be native to mac but if you're if you have a brand new computer you're just starting out in this there are just a few things that we have to go through so we're gonna go to the table of contents and look for visual studio code on mac os page 13. let's scroll all the way down to 13. actually on page 14 here at least according to this we'll find visual studio code on mac os and it's going to tell us where we need to go what we need to download find all the files necessary that being visual studio code and clang so first thing we're doing click on this link right here that should bring up a window we're going to go to the mac version click download click allow that's going to take a little bit of time to pick up and download there okay it just finished so we're going to do so click this open in finder and we're going to take visual studio and drag it directly into our applications like you do with almost anything else once you've done that scroll down since it starts with v it'll be right at the bottom and we're going to click to open that open up in your dock you want to allow it and stuff like that and you should get this uh window here yours won't be as as flickery as oh it actually doesn't flicker in that much on previous attempts at recording this this was a very flickery program we might run into that uh for you it shouldn't be that way for me it's just because i'm running mac os and a vm on windows right now virtual machine that's why you see like this bar up here and and this stuff down here so once we've got it open uh the people at the computer science department because visual studio code is an industry standard and what you'll be using for most of your c plus plus stuff uh would like you to go down here go to options right click on that obviously right click on your program go to options and then click keep in dock all right and once you've got this open we're going to go down to this little some right here these four little squares label extensions going to click on that and it should be in popular but if you don't see it just type in c slash and it should be the first one here you're going to want to click on that and then click install now while that's setting up we're going to do another thing we're going to go ahead and hit the things i just said are all this right here uh we're gonna go down here and it's going to ask you to verify if clang is installed now clang is your compiler that is what will take the code that you write and convert it into something that the computer can understand and execute so in order to run this you're going to want to open up your terminal now i have my terminal kept in my dock down here but in case you don't it's pretty easy uh the easiest way to do it is go into launch pad go up here type terminal and it should be right there and that will open up an instance of terminal now you're going to type right here this has a little uh cache sign here but don't worry about that that's just this symbol right there we're gonna type clang hyphen hyphen version now when i executed that when i hit enter on that command it tells me you know it gives me a little error here no developer tools will f were found and usually it'll prompt you if that's the case it'll prompt you if you want to install clang and developer tools and just hit agree sign all these things that no one ever reads now if this doesn't come up or you're having problems later on and this was never never popped up you're going to go ahead and want to run this command here xcode dash select space hyphen hyphen install but in most cases this little dialog box will pop up and it will give you a prompt to install it okay that says it's installed so we should be able to go down here and type cling hyphen hyphen version or hit up on your arrow path you don't feel like typing that and it'll tell us that we have everything that we need hopefully and now the next thing on the list here this is finished installing but we're going to do one more thing minimize that so the next thing on the list here it's wanting to create a folder to keep all of your projects in for this class so you can put this anywhere for the sake of this video i'm going to put it on my desktop so i'm just going to right click hit new folder and label that go ahead and label that projects if it'll let me rename it there we go projects put that there and once you've created your folder we're going to go in here we're going to create another folder now this folder that you're in right now is just your overarching collection of programs that you've written for each project that you want to start for each program that you're actually going to write you're going to want to make a separate folder so we'll go ahead and call this one hello world because that's what everyone does for the first program once we've named that hello world we're going to double click it to open it now that we're in the hello world directory we can just move this aside close out your applications all right i'm sorry if things jumped around a little bit on my screen or got resized i'd take care of something that wasn't quite working so once you've got your c-slash c plus extension installed and you've taken care of uh checking to see if clang is installed or installing it if need be we're gonna go right back up to these two little pieces of paper called explorer here we're gonna go open folder here we're going to navigate to wherever we have our projects folder which is on my desktop in my projects and we're gonna go to hello world which is the program that we're trying to create hit open it'll bring us into a new window here and we're going to go to this little piece of paper that looks like a plus it's going to open up a box that's prompting us for a file name i'm going to type in hello world dot cpp now everything after the period is fairly important because it's an extension and an extension tells not only the computer but more importantly in our case here uh visual studio code what language it's trying to interpret as you type so after we have it typed in we're going to hit enter it's going to open us up in the hello world okay sorry for another little jump here just for ease of use i've opened up the docx version of getting your computer set up because if you try and copy paste from pdf just from the way it's saved it'll it'll basically mess up your formatting a lot but if you copy from the docx should be perfectly fine just go ahead and select all that ctrl c or command c command v and again everything should be perfectly fine after you do this you're going to hit command s to save that or you can right click on it click say save go up here to file save million ways to do everything so after you have that saved we're gonna go up to terminal as per our instructions here up to a little tab that says terminal here we're gonna click on it we're gonna hit configure default build task and it's going to drop down a little option box for us here and go to the claim plus plus build active file that's going to give us a json file tasks.json and there's some stuff in there but we want to be just a little bit different so once again copy from your docx file this entire string of text here entire block command c select all this command v now if you just outright copy it and try and leave them around press save and then compile and go on with the thing it won't work there's a tiny little error at least in the version that i have the version that you're looking at may be fixed by the time you do this but right under this green text here this comment you're going to want to go in here and put a open curly bracket and we'll try and auto complete that for you just delete the closing curly bracket and that should fix everything on your screen here and i actually missed the closing curly bracket when i copy and pasted it so you won't have to add this last one as long as you copy and paste everything but this beginning one year you'll definitely have to add as long as it's not fixed so once you have that once you've fixed everything hit command s to save again we're gonna go back to our hello world tab we're gonna go back up to terminal here and instead of going to configure we're just going to run build task it'll drop down that oh well it actually didn't usually it'll drop down a another option box here that says you know all the same things it did you're just going to click on uh run clang plus plus build task file or something like that so after that you'll see here yeah your a little dialog box will drop down from up here you're going to want to click on the one that says clang plus plus build active file so once you do that uh it'll give you this little bit of output here you're going to hit this plus here and it's going to open up a new bash terminal and it should open up that's born again shell a new bash terminal and it should open it up in hello world the file that you're in and you're just going to type and it'll actually tell you this here i believe once you scroll down enough it's actually wanting you to go ahead and type out the terminal command for uh like list your subdirectory so just ls and should tell you everything in there to run it we're just going to hit period slash that specifies that you want everything before this in the file path period slash hello world and it should output you know these strings combined here hello c plus westworld from vs code and the c plus extension and if you've done everything correctly uh that should be it you should be ready to write anything you want compile anything you want as long as you follow the few basic steps for setting up a new project like creating your folder and stuff like that i hope this has been helpful to you if you run into any road bumps along the way when you're replicating this feel free to email any of the tas or join the get help discord server feel free to jump on slack and ask any of the tas in your lab or in your class a question and well i hope this has been helpful to you
Info
Channel: Mr. Jim
Views: 33,414
Rating: undefined out of 5
Keywords: c++, mac, vscode, clang
Id: f0vVV4NPmjQ
Channel Id: undefined
Length: 12min 57sec (777 seconds)
Published: Tue Aug 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.