Welcome back. In this video,
we're going to configure the CodeLite IDE that we just installed in the
previous video to work on windows
with the c++ compiler that we installed.
If you haven't installed the c++ compiler,
please go back to that video and install it because we're going to have to need it installed
in order to continue.
So the first thing I want to do is I want to run CodeLite.
Now I've got an icon here right on my desktop. so I'm just going to double click on that.
Now this is the first time I run CodeLite,
and a lot of stuff happens. You get to set up wizards,
you may get this little message at the bottom that says
CodeLite now offers a better editor.
So what I want to do is I want to close this wizard. I'm going to run that
manually in a moment.
So let's cancel that,
and let's select yes down here,
so CodeLite can update our themes.
so I'm going to select ye,
and it says CodeLite restart is needed would you like to restart it now? Yes,
and CodeLite will restart really quickly.
You may or may not get that message depending on
what the CodeLite developers do in the future.So now we're good.
CodeLite is running.
You can see that there's a lot of empty space here.
We've got a workspace view here.
We've got this big old space here in the center,
and I'll explain what all of this is
in a future video I'm going to do a walkthrough of CodeLite
of the entire interface.
But for now what we're going to do is we're just going to get it set up and configured.
So the first thing we need to do is
we need to run that setup wizard the one that I just cancelled.
so I'm going to come up here to help
and I'm going to select run the setup wizard.
Again, help, run the setup wizard.
And I get this little dialog box that says welcome to the setup wizard.
I do want to run it. You only need to do this once, so I'm going to do it first time right now.
I'm going to select next.
Now it's going to ask me about my development profile.
The CodeLite IDE supports web development with
PHP and JavaScript
as well as c++ development.
So if you do both, you can select both over here.
I'm only going to select cc++ development right here this option,
and I'm going to select next.
Now it says you want to set up a compiler.
I don't want to install a compiler. I've already installed it,
so what I want to do is select scan.
What CodeLite will do is it'll scan my system for installed
compilers and set them up for me automatically.
It's important that we set that path variable.
Remember when we installed the compiler,
CodeLite uses that path variable to find the compiler.
So if we scan and it can't find the compiler either it's not installed
or the path variable is incorrect. So I'm going to select scan,
and you see it found my mingw-w64 compiler that I installed,
and you can see the installation path. I'll select next,
that's it.
Now we're going to customize our colors.
You can use the system default or you can use the dark.
The dark is pretty nice and easy on the eyes,
but I don't think it shows up too good on video.
So I'm going to stick to the system default for the video,
and select next.
These settings here for spacing and indentation just leave those as the default
and select finish.
Okay.
It's going to close and restart,
and we're going to get the same interface again.
Now we want to double check that the compiler was set up correctly.
So we want to go to settings, and then select build settings,
and you should see mingw-w64 here when you select
the compilers tab, and you should see all the paths to the
compiler the link or the assembler. All this good stuff that we'll talk about later.
Okay. If this is all empty,
then the compiler was not set up correctly.
And you really need to go back and double check that path variable.
Okay. So at this point, we're good to go.
We're done with the installation and the setup of the compiler.
Now what we're going to do is we're going to write a real simple
program just to be sure that all of this is working correctly.
So the first thing we want to do is we want to create a new workspace.
And I can create that right here I can click on new workspace
or I can come up here and say workspace,
new workspace other place. Now the idea behind a workspace
is workspace is an area and it holds projects.
So we can have a single workspace that contains many projects
and that's the way that I've set up the source code for this course.
The source code is located in the very last section of the course,
and it's organized into workspaces.
So you can download workspace for section 5,
and it's going to have all the projects that I did for section 5.
It's a very nice way to organize projects.
So again, it's just a basically an area where you can have different c++ projects.
So let's do that. I'm going to select new workspace,
and the first thing it asks me is
what kind of workspace.Is it a file system workspace or a c++ workspace?
I'm going to select c++ workspace, and click okay.
Now it's going to ask me where do I want to store it and what's the name of my workspace?
Well, I'm going to store it in my documents folder,
and I'm going to call the workspace
FirstWorkspace.
Okay. Now I strongly urge you to click that to check
this little box right here, which says create the workspace under a separate
directory that'll really help you keep your files organized,
so you can see what's going to happen,
it's going to generate a file called firstworkspace.workspace,
and it's going to be in this FirstWorkspace directory, which is exactly what we want.
I'm now -- there's a word of caution here,
do not use spaces here,
do not use special characters like pluses. I mean don't do like
something like c++ workspace that's going to cause all kinds of problems.
No international characters, no spaces.
So keep the naming very, very simple.
If your username -- for example,
my username here is Frank.
If your username has special characters or international characters,
then don't use it, create this somewhere like
CPP or somewhere else.
Create it in a folder that doesn't have all of that in it. Okay.
The last thing is finally be very aware that these compiler
tool chains which is what we're using are very very picky about names.
Don't store these on cloud drives,
like google drive or DropBox or OneDrive.
They can cause a lot of issues. So again, store stuff locally.
All right enough said. So I'm going to store it in FirstWorkspace,
and I'm going to select okay.
Now you can see over here in my workspace view on the left
that I've got my very FirstWorkspace.
Now in and of itself, the workspace isn't really doing anything for me.
It's just a holder for projects.
So what I want to do now is I want to create my first project.
So I can right click on the workspace and select new, new project.
So I'm going to select that and now here we get a whole bunch of options.
First, we need to name our project. So I'm just going to call it project1.
Again, you can name it anything you like. Don't use spaces, don't use special characters,
don't use international characters.
Check this box right here, so it creates the project
in its own folder that's important,
that way we can create many projects within the workspace
and they're all nice and separated.
Now we've got a whole bunch of options here.
It's important that you choose the right options. The first one is the category.
So I'm going to select that. The category is going to be console.
You can see that there's a whole bunch of other ones.
Console is the one we're going to use, which is basically a non-graphical
user interface,
and it's going to go to your command prompt.
That's where the output's going to go.
So console, the type of project
is simple, executable G++.
Okay. Don't select any of these other ones.
Those are all GUI-based and Macy make projects. We don't want any of those.
We simply want simple executable G++.
G++ is the compiler we're using.
Now what's the compiler.
Remember, we installed the compiler and then we just set it up in CodeLite.
So when i select this, it should show it to me.
And there it is mingw.
We can install multiple compilers on our system.
If you do that, you'll get a choice here of 2 or 3 or 4 or as many as you've installed.
I only have the one installed, so I�m going to select it.
The debugger,
select GNU GDB debugger.
This is the one that's used in windows.
The LLDB debugger is the one that's used on mac,
but this is a windows, video. So I'm going to install
that guy.
I'm going to select the GNU debugger rather.
And then finally, this one here. This one here is the most important one of all.
You've got to make sure this is set to default.
If it's set to anything else, you're going to run into build issues.
So set it to default. And you notice that it defaults to CodeLite make generator.
Don't select it, select default.
And now we're good to go. So let me go through this because this is really important.
This is where most of the errors come up with the projects.
We name our project using
non-international characters and so forth, as I've mentioned already.
Created in its own folder, the category is a console-based application.
The type is simple executable G++.
Compiler is mingw or whatever compiler you installed.
The debugger for windows is GNU GDB.
And later on in the course, we'll use a debugger and I'll show you how to use a debugger
to find errors and walk through your code.
And then the most important one your build system default.
Okay. So you can pause the video here while you set yours up
and make sure you get these just right.
Okay. So now I'm going to select okay.
And when I do select okay, you're going to see a project being created over here,
called project1 in my workspace. So I'm going to select okay,
and you can see that project1 has been selected.
It has a source folder,
and within it is main CPP.
Now main CPP or main.cpp is our c++ program.
Our source code, that's where we're going to type in our program
that tells the computer what we want to do.
Now I can't see that source code yet,
but when I select it that source code will appear here in my editor.
So I'm going to select it.
I'm going to double click it, and you can see that it's right here.
Now we're going to erase this in a minute and write our own,
but you can see that there's my source code right here, now it's pretty small
because I just installed CodeLite.
So I'm going to make this font a little bit bigger
so it shows up better on the video.
So I'm going to select. You don't necessarily have to do this unless you want to
but I'm going to select colors and fonts.
And let's see I'm going to select it's 9.
Now I want to select 16
that should be a lot better so I'll apply okay
and hopefully That'll be a lot easier to read.
Okay. So as I said, I'm going to delete this code right now,
and we're going to write. This is actually C code.
We're going to write c++ code.
You're probably going have a lot of questions. What does this mean?
What does STD mean? What is all this stuff?
Just follow along, type along. Let's get a clean build and run going.
All of this is going to be explained in the course, as we go through it.
So let's do this. Pound include
and by pound, I'm using that hashtag symbol,
then I've got
iostream inside angle brackets.
This allows us to do input and output.
And then we're going to write our main function,
every C++ program has to have a main function.
So it looks kind of like this, int,
the word main
and then a left parenthesis followed by a right parenthesis.
Then I've got a curly
and a closed curly,an open curly, a left curly and a
closed curly right here right curly.
Notice that when I put that left curly in,
I'll do that again and press enter
the integrated development environment
automatically closed it for me.
That's my main function. Now within those curlies,
I'm going to type STD followed by 2 colons,
followed by C out. No spaces just
STD::Cout.
Then I've got two less than signs,
side by side. No spaces between them.
And then I'm just going to say hello testing.
And all of that is inside that double quote character.
It's not two single quotes, it's the double quote character.
And then I'm going to say again less than, less than
std::endl
for endline and then the whole thing ends in a semicolon.
It sounds like a lot.
All we're doing is we're displaying hello testing to the console.
That's all we're doing. Cout is the console,
endline puts a new line at the end so that we go to the next line.
Okay. Again, I'll explain all of this in the next couple of sections.
So now what I'm going to do is I'm going to type return zero
that tells the operating system that our program
worked correctly.
Perfect, now I need to save this.
You'll notice this red bar right here,
that's going from 1 through 6 right there.
That's red that means that none of this has been saved.
So I need to save this. I can come up to file,
save a file or I can press ctrl S.
I'm going to just click there.
Notice that that bar is now green
that means that you have saved your program.
Okay. Now we're going to build and run this.
So we're going to come up here to build and run.
But before we do that, we need to set up a couple of things
for our project. We want to use modern C++.
We want to turn on warnings, and we want to do a couple of other things.
So how do we do that? I can select my project right here,
and I'm going to right click and I'm going to come down to settings.
And then I've got all these options. Luckily we don't have to change too many of these.
This is already set up that project
wizard that we just did to create this where we chose
console and simple executable and default all that.
That's filled all of this out for us.
What we need to do is we need to come to the compiler one right
there that link right here,
and we need to make a couple of little changes.
We're going to come to the c++ compiler,
not the c compiler with the c++ compiler.
And I'm going to select
that right here notice those three little dots that show up over here that little button.
I'm going to select that button
and I'm going to select enable c++ 17 features right here.
In this video, the majority of the videos that I've done
are using C++ 14 features.
You canchoose 14 or you can choose 17.
Do not choose both, that will really confuse
the compiler.
So I'm going to select c++ 17 features now.
And notice what's down here
w all which turns on all your warnings.
And I've got a minus g and a minus optimization here the big O,
that's it. That's all I really need to do.
So you want to make sure that you've got you enable all the compiler warnings,
enable c++ 17,
optimize for debugging
and produce debugging information.
That's where all that's coming from. That's all we need to do.
I'm going to select okay now,
and one more thing come to the linker
and then where it says linker options right here.
You can just type -static
and then we can apply.
You don't have to do static but a lot of errors can come up
without static and it's a lot easier just to learn c++ without those errors.
And if anybody has any questions about that,
you can ask me in the forums, and I'd be glad to get into more detail.
That's it. I'm going to apply select okay.
Now we're ready to run this. Again, make sure this is green here,
it's good to go. So I'm going to come to build,
and I'm going to select run.
And here I've got the choice of executing it or building it and executing it.
Again, I'll talk a lot more about the workflows in future videos,
but we want to build it and then execute it. We want to compile it obviously.
We have to compile this so that the computer can run it. So that's what I'm going to do.
I'm going to select build and execute down here at the bottom.
You'll see a bunch of stuff happened right. This is my output
and this is my build. And you probably saw that little console window a second ago,
and you can see it says hello testing. That's exactly what we want.
Our program worked correctly. So this is being compiled and executed.
We've got a command prompt window opening up, displaying the text.
It says press any key to continue. I'm going to press enter
and the window will close.
Andit's gone.
And down here is
the output view. There's a
whole bunch of stuff here we really are going to talk most just about one or two
of them. The only two we care about are really build and output.
And you can drag these around and put them wherever you want. But build tells you
what's the build.
Here you can see my compiler is being executed,
and it's compiling stuff and it's doing all kinds of stuff.
So if you run into compiler errors and issues, they're going to show up here.
If in the forums, you'll post something about something not quite working,
I might say show me your build output,
this is what I want. I want you to grab this stuff right here
and copy it in there or just give me a screenshot and post it that'd be really, really helpful.
Now what can go wrong? Well, let's say you forgot the semicolon
and notice that little red bar there, right. That little piece right there
says that that's been changed.
So I'm going to save. I'm pressing ctrl s here.
Now it's green. I can go to build, run.
Build and execute you can click on there if you like but don't do that yet we'll do that in a future
video when I'll show you more about building build and execute
see the red that's an error.
It says error. I expected a semicolon.
Like hey you forgot to do the semicolon.
Notice this is red.Notice that
if I click there,
it takes me right to the error. There's a red arrow right here
and it's telling me obviously I forgot the semicolon. So I'm going to save again.
What else could go wrong? I forgot this quote mark.
Again, I'm going to build and run.
Well, an error right. Double click,
I'm forgetting that. So
these errors, I'll talk about different kinds of errors, common errors,
again, in a few videos.
The other thing that I've seen that's common is
to put a 0 here instead of two parentheses. These are two parentheses
not a 0.
I know they look very, very similar sometimes when you do the 0 like that.
But there's a left parenthesis followed by a right parenthesis.
Okay. Main must be spelled correctly and iostream.
Sometimes students will forget the r,
and you'll see iosteam. Iosteam, the compiler will have no
idea what that is. So if you build and run,
that's it. No such file you're going to get all these errors like I have no idea what's going on.
So you can fix that as well. It should be iostream.
So that's it. This com
this is configured now let me build and run one more time make sure we got rid of all those errors.
That's it. We have a clean build down here. Notice 0 errors, 0 warnings.
And I've got a clean run hello testing
press any key to continue, and we're done.
All right. So that's it. We're good to go. We're ready to start writing c++
programs. And I'll see you in the next video.