(upbeat music)
Frank: Hello everyone.
In this video what we'll do is we'll download and extract
the source code provided in the course,
and we'll set it up so that we can use it
with Visual Studio Code.
The source code is located
in one of the last sections of the course,
right now it's in section 22,
but that could change as I add content to the course,
that probably becomes section 23 and then 24 and so forth.
So the best thing is to search
for a section named
Extra Information, Source Code, and Other Stuff.
And in there there will be a video,
Source Code for All Sections.
And when you select that, this is what you're going to get.
It's a bunch of links to zip files
that contain the source code for the course projects.
So what you wanna do is,
depending on which section of the course you're in,
you want to download the zip file for that section.
So in this case,
I'm going to download the source code for section four
and I'm just going to click on there,
and that will download a zip file,
which I'm just going to save.
Now that I've saved it, I'm going to go to my downloads
and I'm just gonna extract it.
So I'm just gonna Right Click and extract right here.
All right, so this is what we've got now,
you can see it's extracted it to a section four folder,
and inside that section four folder are all the projects.
So what I want to do
is I want you to just copy this section four folder,
or you can cut it if you like, to the desktop,
just so I can show you how to do it here.
So now I've just downloaded and extracted
all the projects in that section,
into this section four folder.
So I think you know what to do now.
What we want to do is we want
to open up this section four folder in Visual Studio Code
and then set up IntelliSense, the tasks JSON
and the launch JSON again, so let's do that.
I'm gonna close all this up 'cause I don't need it anymore.
And what I want to do now is I wanna open a folder.
So again, we'll open folder,
and I'm going to go to my desktop
and I wanna open section four, that's the one I want.
So I'm just gonna click OK.
And now you'll see that section four
was opened up in Visual Studio Code,
which is exactly what we want.
You'll also notice that there are some folders
like codelite and MakeFile and things like that.
Don't worry about those.
Those are things that CodeLite needs,
Visual Studio will just ignore them.
But we need to configure this to work with Visual Studio.
So we have to go through the same process
that we did before.
We have to do it once per major section.
A couple ways to do this,
we could do it manually like we did before,
which is what I'm going to do here,
just so you can see it one more time.
Or you could copy your VS Code folder
from an existing project into this project.
Okay, so let's just do it manually.
First thing we want to do is I wanna close this get started
and I wanna click on any of the,
let's see this guy right here,
any of the main.cpp files in there,
any C++ source file is what we need.
And then we're gonna go to view, command palette,
and type in again, C++,
until we see edit configurations UI.
We're gonna set up the IntelliSense again.
We'll scroll down and make sure that we've got,
so we'll scroll right here to compiler path
and we want to be sure that we are using g++, right there.
And then we're gonna scroll down a little bit more
to the C++ standard and we're going to choose c++17.
That's it. I'm gonna CTRL + S to save
and I'm done with that, perfect.
Now you notice we've got our VS Code folder here
and our CPP properties are set up.
So again, I'm gonna select main.cpp,
and I'm gonna come up to terminal,
and configure the default build task.
I'm going to select g++.
And now once I'm here,
I'm gonna make those same changes we made before,
we're gonna enable all warnings.
So -wall.
We are going to enable the c++17 standard,
and we're going to change the file on line 12
to fileDirname.
I'm going to copy this and I'm gonna paste it right in here.
And then finally we're going to add the /*.cpp,
so that will compile all the files.
Now when we do these,
you'll notice is sometimes you'll see squigglies.
So for example, if I get rid of that comma,
you'll see some squigglies show up, right?
We don't want any of them, those are errors.
And we just wanna be sure that everything looks clean.
If something doesn't look clean,
look at the video and make sure
that you haven't missed any quote marks or commas
and so forth.
So that's it, I'm going to save this
and I'm gonna close this up.
Now what we'll do is we'll select main.cpp on FirstProgram,
and you can see what the FirstProgram is doing.
It's similar to what we did before with the favorite number,
what I want to do now is just test it out.
So I'm gonna select that and I'm gonna go to terminal,
and run the build task.
So that will build our project,
and you'll see build finished successfully.
So remember, the main executable was created right here,
right inside that project.
So I'm gonna right Click On it, open an integrated terminal,
and then I'm gonna type ./main.
What's my favorite number?
Let's say it's 34 this time.
Amazing, that's my favorite number too.
That's exactly what we're supposed to get.
Okay, perfect, so now let's say I wanted to run Project1.
I can go to main.cpp there,
and again I can come up to terminal, run build task.
Now it's going to build Project1.
And you could see from the message right here,
you could see Project1 is being built right there.
We've created our executable within Project1,
which I can Right Click, open in the integrated terminal.
And you can see Project1 just says Hello Project one.
We can run it again, and now we're running Project1.
So this is a real easy way to organize yourself,
and to get everything running nicely.
We're done with that.
The last step is to get the debugger working.
So what we can do now, again,
select one of the main.cpp files, there's one.
And we come up to run and add configuration
and select c++ GDB/LLDB, and then g++.
We're gonna get some stuff happening,
whatever happens, just let it happen
and then just kill it right here.
So I'll press that little red square.
And now what we want to do
is we want to come back over to our explorer
and we want to edit that launch.json file.
And all we really want to do is change this guy right here,
this current working directory,
I wanna change that to file directory name.
So I'm just going to copy and paste.
That's it, I'll save.
And let's pick FirstProgram again, so right here.
And let's say that this is the one we want to debug.
So what we can do is we can click on the bug,
if there are any break points done here, we can clear them.
We will add our own break point,
let's say we want to add a break point right on line eight,
and then we select that little green play button
right up here and the debugger will engage.
You can see where we're stopped on line eight,
and you can see my favorite number's over here.
Lemme just move over.
Now you'll notice that we're getting 32767.
What in the world is that? I don't see that anywhere.
Well, we haven't initialized favorite number to anything.
So whatever displays here really is undefined,
and I'll talk more about that in the class,
that's really an important issue with C++.
So now we could just step through the program.
Let's step through right here.
Enter your favorite number between one and 100.
So let's say I wanted to enter 56 and press Enter.
Now we're on line nine and I can step over that.
Also, notice my favorite number changed here,
and I can hover over to see that it's 56,
and when we're done we could just finish and that's it.
So that's how we can get the source code
provided for the course to work with Visual Studio Code.
It's really pretty easy once you get the hang of it,
you can set up the tasks JSON and launch JSON files
really quickly.
Or like I said, you could just copy them and paste them
into the new structure that you're creating.
Alright, so that shows you how to set everything up
for Linux Ubuntu, I'll see you in the rest of the course.