Welcome back. Now that we've installed the c++ compiler
and the CodeLite IDE, it's time to run CodeLite,
get it set up and configured so that we can start writing c++ programs.
So the first thing we're going to do is we're going to run CodeLite. Now remember, we just installed
it in the previous video. If you haven't installed the compiler
or CodeLite, please go back to the previous video and do that.
So what I'm going to do, I'm just going to click on my applications down here,
and I'm just going to type CodeLite,
and you can see the icon here. If you right click on it, you can add it to your favorites over here
on the left side. But I'm just going to double click it to run it.
Okay now thefirst time that CodeLite runs,
you may get this message down here
at the bottom that says CodeLite now offers a better editor color support theme.
If you don't, it's probably -- that's fine, it's probably a newer version of CodeLite.
In this particular version,
I'm going to click yes. But before I do that, we're going to run a setup wizard.
And I just really want to get rid of all this clutter.
Let's do this in a specific way. So I'm just going to cancel this wizard.
I'm going to run the wizard in a moment, but I'm going to run it manually.
And let CodeLite do its thing here.
So I want to fix this now. I'm just going to select yes.
It says now a CodeLite restart is needed. Would you like to restart now?
Yes.
CodeLite will now close for a second, and it'll open up automatically.
And you can see that this is the CodeLite interface here. We've got this left side here.
We've got all this white space here. Now it hasn't been configured yet.
So we want to run that setup wizard that just popped up a second ago.
I want to run that manually. So if you come up to help,
you can see run the setup wizard right there. That's what I want to do.
So I'm going to select that
and, it says welcome to the setup wizard.
Now we only have to do this one time. We don't have to do this every time we run CodeLite.
So at this point, I'm just going to select next.
It's going to ask me for my development profile.
The CodeLite IDE supports CEC++
development PHP, JavaScript and so forth.
I'm only going to use c++. So I'm just going to select
c/c++development.
Then I'm going to select next,
and this part's really important. IT says
let us set up your compiler for you.
Remember, we've already installed the compiler but the compiler has to be able to work
with CodeLite, and that's what this step does.
So we're just going to let CodeLite scan our system for
the compiler that we installed. So I'm just going to select this big button right here scan,
and I'll select that.
And you can see that CodeLite found the compiler and you
can see there's several compilers here.
It's really the same compiler. It's just using three different names.
That's fine. Just select next.
Now we can customize our colors.
This is just the color for the CodeLite interface.
I'm going to stay with system default because I think it looks better on video.
The dark theme is really nice on the eyes.
And if you like the dark theme, I'd suggest you do that one because it works great.
But like i said for the videos, I'm just going to keep the default.
I'm going to select next.
I'm going to leave these settings as they are for the white space and indentation.
And I'm going to select finish.
CodeLite closes up and then it will reopen again.
Now let's be absolutely sure our compilers are set up correctly.
You can do that by going up to settings,
and then selecting build settings.
And you can see the compilers have been set up here.
We're going to use GCC in our code.
But you can see that we've got different versions of the compilers here.
And as you can see the paths here have been set up for us,
which is perfect that was the whole point of running the setup wizard.
If these are empty over here,
then you really need to run your setup wizard again
or maybe even install the c++ compiler again because something's not right.
Now what do we do? Well, we need to start writing our code.
Well, in order to do that, we need a workspace.
The way that CodeLite works is, it uses a workspace
that contains projects.
So each one of our projects is a c++ program,
but they're housed in workspaces.
but they're housed in workspaces. need to do is we need to create the workspace.
We can do that right here by selecting new workspace
or we can do it up here by selecting workspace,new workspace,
again either place works fine. So I'm just going to click this button right here.
New workspace, and I get this pop-up window that says what kind of workspace
type you want to create?
Well, I want to create a c++ workspace, that's what this class is all about.
So I'm going to select c++ and select okay.
And now where do I want to store. It basically where do I want to save
these workspaces. So in this case, I'm just going to put it right in my documents folder.
And my workspace name is I'm just going to call it first workspace.
So I'm going to type FirstWorkspace.
Now before I continue it's really important,
I can't tell you how important this is. This is where most of the errors come up
with building.
Be sure that you don't use any spaces in here.
Be sure you don't use any special characters in here.
Keep it really, really simple. No international characters.
Okay. So I'll say that one more time. No spaces.
No special characters. No international characters.
Those things cause all kinds of problems with building.
So we want to keep the workspace names real simple,
and that applies to project names and file names and
everything else we do when we write c++ code.
It's possible that your username you can see my username here on
my ubuntu machine is Frank.
It's possible that your username may have
strange characters in it or international characters. If that's the case,
find a different path to store this to
make sure that all these characters are just really, really simple.
So that's it. Workspace, I'm going to call it FirstWorkspace.
You can see where it's going to be created.
And it's going to create a file called FirstWorkspace
.workspace that's the name of my file.
Be sure you click down here, and make sure that's checked.
Create the workspace under a separate directory that'll
really handy because it'll keep everything nicely organized.
That's it. Select okay,
and you can see right over here on the left side where my mouse is that
we've got our first workspace. Now in and of itself,
a workspace isn't really do anything for you.
The whole point of the workspace is to add projects to it.
And that's what we're going to do now.
So we're going to add a project to the workspace.
We can do that by clicking on the workspace and then right clicking
and selecting new, new project.
Okay. So let me do that again right click on the first on your workspace,
new, new project. I'll select that,
and now we get this new project dialogue.
And there's a whole bunch of settings here,
and these are really really important to get right.
First of all, we're in the workspace we created. That's exactly what we wanted.
So now what's the name of the project?
Well, we can have multiple projects in the workspace, as I said.
So I'm just going to call this project1.
Again, no spaces. No special characters. No international characters.
Make sure that this check is checked. Create the project in its own folder
that will allow us to have
one folder for each project we create that keeps it nicely organized.
Now these settings here are really important to get right.So I'll go through them really slowly.
The first one is category.
The category is going to be console. You can see we can create graphical
user interfaces, templates, all kinds of stuff.
We want to create a console application.
That's an application that runs in the terminal window.
The type is going to be simple executable g++.
Okay. Again, really important simple executable g ++.
G++ is the name of our c++ compiler.
It's got the g because it was created by the gnu foundation.
So, again simple executable g ++.
Don't choose any of these other ones or you're going to get all kinds of build problems.
The compiler. Remember, we ran that setup wizard.
So now we're going to come to compiler. I'm just going to choose GCC.
The debugger, we want to choose the gnu GDB debugger.
And then this last one is the most important of all which build
system do we want to use. Make sure that you choose default.
Okay. So I'm going to leave this here for a second. You guys can pause the video and double check.
But I'll go through it one more time. Category is console.
And before that, make sure that you've checked this little checkbox here.
So we've got category is console.
The type is simple executable g++.
The compiler is your GCC compiler.
The debugger is the gnu GDB debugger.
And the build system, very important that it's default. Okay.
Once we do that, we select okay
and what you'll see is you'll see over here in the workspace view on the top left.
You'll see a project, project1 being created under it. So I'm going to click okay.
And you can see that our first project is here.
See all this white space over here on the right. That's where we're going to be
typing our code. So you can expand these
little chevrons here.
And you can see that our project1 has a source folder in it,
that's where our source code is going to be.
And in there, there's a file called main.cpp.
That's our first c++ program.
So I want to see that. I want to edit that. So what I want to do is double click it.
And when I double click, it it'll show up over here in this white space. So I'm going to double click it.
And you can see the source code right here.
And this is what we want to set up.
Now what I'm going to do is I just installed CodeLite fresh on this system.
This font is a little bit too small for video. It's probably fine on your end.
But for video, it's a bit small.
So I'm just going to go to settings. You don't have to do this.
But I'm going to set my colors and fonts.
And let's see. I just want to set my font to
16,
something like that. I'll select that,
and I'll select apply and okay. And
that should be a little bit more readable for you guys on the video side.
All right. So we're almost there.
What we're going to do is, this is actually c code and not c++ code.
So what I'm going to do is I'm going to delete this code right here,
and we're going to write our very first c++ program.
And we're going to do that right now. So I'm going to select all this code here,
and I'm just going to press backspace or delete just to delete it.
Now I'm going to type a few lines of code.
Please just type along,
follow along. I know you're going to have a lot of questions. You know what does this mean, what does that mean.
Hang in there, stay tuned as they say.
It'll all be explained in the course. But first we need to be sure that we've got
our project set up correctly and that we can run.
Okay. So let's start. We're going to type pound include
and then iostream
in angle brackets and I'm going to press enter.
Pound include again the pound is the hashtag symbol
pound include space and iostream in angle brackets.
That's a less than and a greater than sign on each end.
Then I'm going to type int
main
followed by left parenthesis and a right parenthesis.
Then I'm going to type in a left curly bracket.
And notice when I typed in that left curly bracket, I'll do that again.
I'll type in the left curly note and press enter.
Notice that the IDE closed it with the right curly.
Okay. The IDE will do that automatically for you.
It'll match it up. So right in here, I'm going to type std
Followed by two columns ::, followed by cout
a space, two less than signs, again, no space between them <<
and then I'm going to type hello testing inside double quotes,
just like that.
Again, <<std
::endl;
and then right here, I'm going to type return zero.
So let me go through this one more time be sure you get it just right. Int main
left paren, right paren, open curly,
std::cout altogether no spaces.
Then we've got a space << hello testing in
double quotes.
Again, << and then std::endl.
All we're doing is we're including the iostream library
which allows us to do input output. We're going to do output in this case.
And in this case, all I want to do is I want to display
hello testing you can see it right here. I want to display hello testing to the screen.
And this is how we do it. We output it to the cout, which is our our console.
And then we're going to put a new line on the end. That's it.
We're returning zero because we always return zero
from main. I'll talk more about that later on.
And that's it.
Now you'll notice over here, I've got this reddish orange bar
that's going from 1 to 6.
That means it's actually red on my system. It might show up orange
some on video. Sometimes it does. That just means I haven't saved this yet.
It's really important that I save my file. So I can come up to file,
save file here or press ctrl s,
either way.
I'm just going to press ctrl s, and you'll
see the color change. I'm going to press ctrl s,
and notice that now it became green
that means it's saved. That's really important. Be sure that you save your file
before you try to build it. Otherwise you may not get what you expect.
So that's my program. It's a really simple c++ program.
It's got some stuff in there that I know you've got questions about.
. As I said, stay tuned, it's all coming.
Now what we need to do is we need to build this and run it.
But before we do that, we need to set a few settings for our project.
So let's do that. Click on your project1 right here.
Right click on it, and then all the way down at the bottom, we're going to see settings.
So select settings.
Now you'll notice that the general is set up right here.
Right, that that's been selected.
And all this stuff on the right is stuff that was already set up for us from that
project wizard,
the new project wizard. We don't have to mess with any of that.
What we do have to change is we're going to go to where it says compiler right here.
And then I'm going to come up to where it says c++ compiler options.
And right here, you'll see a -g, a -o and a -wall and all this other stuff.
I'm just going to click on there.
And you'll see a button that pops up right over here on the right
with three dots. I want to select that button.
And now we've got all kinds of options that we can set for the compiler here.
We're just going to set a few options. Actually, we're going to leave the same options that are there.
But we want to add one more. We want to click right on here where it says
enable c++17 features.
Now in this course, I've used mostly c++14.
And that's what you're going to see in a lot of the videos.
But this version supports c++17,
and they're very very very similar.
The only differences between them are going to be explained in the course,
and most of them are more advanced and they're not they're not going to affect learning
basic foundational modern c++.
These are the settings we need to have on.
Enable all compiler warnings,
enable c++17 features.
I'll scroll down a little bit here,
optimize for debugging
and produce debugging information.
So those four settings are what you see right down here in the command line.
So I'm just going to click okay, apply
and click okay again.
Now finally we're good to go. Let's run this. We can come up to build,
and we can type build and run project
right here. That's what I'm going to do. I'm going to select build and run project.
And you could see down here a bunch of stuff just happened really quickly.
First of all, the good thing that happened is we popped up this terminal that says hello testing.
Hey that's what we wanted, right. That's what our program was supposed to do.
And then it says hit any key to continue. So I'm just going to press enter.
There notice the window popped away, which is what also what I want.
There's two tabs down here that are very important.
One is the output tab. This is just -- this is not the output of your program.
This is the output of trying to run your program.
So this is what opens up that terminal we just saw.
The other one that's really important is this build tab right here.
Those are the only two that we generally will use in this class.
So I'm going to select build.
And you can see right here that your compiler is being executed.
You can see those switches, those compiler options right over here that we just set up.
And the good thing here it says zero error, zero warnings.
What could go wrong? Well,
you maybe you forgot this semicolon here.
And then notice again that I've got that little orange red right here, right. I need to save that.
So I'm going to ctrl s and save.
And then again, I'm going to go to build, build and run.
And notice that I've got errors. Do I want to continue? No, I don't want to continue.
But notice my build output. You see the error right here.
It's red. If I select that and click on it,
it takes me up to the code
and what happened was here's the error. It's expecting a semicolon.
So I forgot the semicolon.
Now if you type this program, again, I'll save it as is -- if you type this program exactly
like I typed it, you shouldn't get any errors.
If you do and you post in the forum, I might say something like,
can you show me your build output? This is what i want to see,
just copy and paste this stuff or give me a screenshot that way I can
exactly see what's going on.
Now typical errors are that forgetting a semicolon,
forgetting to put a quote mark here. We've got a quote mark here,
and we've got another one here. Sometimes students will --
these two parentheses sometimes when they're together, it looks like a 0,
like that they'll put a 0 in here and that'll be a mistake.
So this is a left paren followed by a right paren.
And another common mistake is to to iosteam here.
I don't know why, but a lot of people do that.
So it's iosteam that's incorrect, it should be iostream.
So any one of those will cause an error down here.
All right. So that's really pretty much it for this video.
We're all set up to run c++ programs.
If you have any errors, post them on the forums along with the build output.
And I'll get back to you with the fix.
Okay. So let's learn c++.