Welcome back.
In the last video, I installed CodeLite on Windows
and I created a shortcut icon on my desktop right here.
So if I double click that, that's going to open up and run CodeLite.
And the first time you run it, you're going to get a setup wizard.
It's going to look something like this, it says welcome to the setup wizard,
you can bypass the setup wizard but let's run it.
And we'll select Next
and we'll select C++ development,
select next again.
Now, in this step,
you can scan for compilers.
And the idea here is we've got a compiler installed on our system.
CodeLite needs to configure itself to work with that compiler.
So, we'll select Scan.
Most of the time it will not find it
and in this case,
it did not find, it okay, just like expected.
Do you want to install one?
It thinks we don't have one yet, so don't install anything,
just close this up and we'll manually configure it in a moment.
Don't worry about what shows here,
I've got the Microsoft C++ compiler installed as well along with the
new C++ compiler.
So, most likely, you're only going to see rust so just click Next.
Here we select the colors that we want for our interface.
Normally, I will work in dark.
I'm just going to select System Default because I think that the light
actually I'm going to select light because I think that the light
shows up a lot better on video than the dark, so I'm going to select next.
I'll just press Finish now, don't change any of these settings
and CodeLight is going to close up and restart
and that's it.
So let me make this a little bigger and show you what's going on here.
We've got our menu at the top and over here on the left we've got a workspace view.
In the workspace view is where we see our workspace and our workspace
can consists of many projects
which is really great because we can have
a workspace, for example, for section six
and have all the projects related to section six in here.
Or you can have a workspace named anything you want, maybe you're learning about
pointers and you want to create a workspace called pointers
and then having projects within that workspace all about pointers.
Once you have workspaces, they'll be available down here.
Recently open Workspaces, obviously I've just installed this so I've got nothing in here.
So that's a real easy way to pick previously used workspaces.
And then you see this right over here where it says
open an existing workspace, create a new workspace
and so forth and we'll be using those in just a moment.
But before we do anything, we need to set up
and configure our compiler, so let's do that.
I'm going to go up here to Settings and then I'm going to press Build Settings
and there you can see those three items that we saw a little while ago during our build.
Now at this point, I want to click that blue plus symbol right here.
On some versions, I think it's the Linux version of the Mac version,
that's a green plus, but in this case, it's a blue plus.
So, I'm going to make sure, I'm on that compilers tab right up here
and I'm going to click that plus it says add an existing compiler,
so I'm going to click it.
Now, I'm going to go to where I installed my compiler
and I installed it on my C drive
in the mingw folder, right there,
and I want to select the bin, that's the path that I want.
That's where all my binaries are, the executable files for the compiler
and I'm going to select folder.
At this point, it's asking us to name the compiler.
I'm going to name it MinGW, just like that.
I encourage you to do the same, select OK.
And now, CodeLite has set up the compiler, you can see it,
set up the compiler path, the assembler paths and all this good stuff.
And a good sanity check is to look through here
and make sure that you've got MinGW 64 bin because that's where all this stuff is.
And once we're done with that, we can click OK, great.
Now, we're in a position where we can start writing code,
creating workspaces, creating projects and so forth,
so let's screw through those steps.
There's still a little bit more configuration, but not a lot more.
So, what we can do here?
Is we don't have any workspaces yet,
so we can create a new workspace.
I can click over here on this big button over here on the right,
or I can go up to workspace, new workspace,
and I think you can even do a file, New Workspace,
yes, right there.
So, there's a lot of different ways to do it.
I'm just going to click on this big button because it's pretty easy.
Now, it's asking us what type of workspace do we want?
We want a C++ workspace,
so make sure you select C++, click OK.
So now, it's asking us where do you want to store this workspace?
So here, you've got a lot of choices.
You can store this wherever you like, sort of,
do not install this on cloud drives,
do not install workspaces on folders with really weird names.
And the other thing I would recommend is not to install it on your desktop or your documents.
I used to do that all the time and it worked great,
but more and more we have systems that are using OneDrive
and OneDrive is managing the desktop
and the documents folders and it's putting them somewhere else where they
normally aren't.
So what I would recommend is that we go right in here
right in our users and whatever your username is, my name is Mitro
in this example, that's going to be your own username.
What I encourage you to do?
Is just click those three little buttons here.
And right now, I'm in the home folder,
and right in here, I want to create a new folder
and I'm just going to call this Workspaces.
Just like that, and I'm going to select that.
So, my workspace path is my
home directory, my user's username folder,
and I want to create a new workspace, so let's call this workspace one.
We can call it, whatever we want.We can call it, you know,
this week's workspace, whatever you like.
Now, what something that's very important?
Do not put spaces anywhere.
Do not use special characters, just keep it really, really simple.
No international characters, no spaces, no special characters,
just keep it plain and simple,
these build tools are really, really picky about that, so that's my workspace.
Make sure that create the workspace under a separate directory is checked
and click OK.
Now, you can see over here on the left that we've got a new workspace that's been created.
And that's great, that's exactly what we want.
But we need projects within that workspace.
And the projects themselves are each going to be a C++ program.
So how do you think we create a project?
Really easy.
Click on your workspace, you can come up to file, new project.
Or we can right click on the workspace
and create a new project, that's what I'm going to do.
Now, we're going to get a new project wizard.
Notice the path is the workspace one that we created.
Now it's asking us what's the name of your project?
I'm just going to call it Project One.
Remember, we can have as many projects as we'd like within that workspace.
Make sure create the project in its own folder is checked.
And now, these are really important settings here, what's the category?
We want to build a console-based application.
That's an application that runs in a console window, a command prompt window.
We're not doing graphical user interfaces, that would be a whole different course.
The type
is going to be simple executable G++.
Now it's asking us, what compiler did we install?
Well, we installed the MinGW compiler, that's the one that we installed a minute ago and named it,
so I'm going to select that.
For debugger, you can choose the GNU gdb debugger.
And now for the build system.
This is where the developer that created CodeLite,
really changed things up in 17.3.
For years there has been a default build system in here that worked great,
he got rid of the default build system, I don't know why, but he did.
So, we have to work without that now.
And what we're going to choose is?
CodeLite make file generator.
Let me click those again and it should just be there when you start but just to be sure.
You've got a couple of options here,
CodeLite make file generator is what we want.
So that's the one I'm going to choose and I'm going to click OK.
Now, we've got a project over here, it's got a source folder.
That's where we're going to put our source code.
And it's got a main.cpp file.
The main.cpp file is RC++ source code
and the name of the file is main.cpp.
So, let me double click that and that's going to open it up here
in my editor.
This is where I can change my program, add code and so forth.
I'm going to go to my settings for a minute
and I'm going to go to my colors and fonts and I'm just going to make this
font a little bit bigger, just so it's easier for you all to see.
You don't have to do this,
but I think it's going to make a big difference here, there we go.
So now, what we're going to do is?
We're just going to get rid of all this, because that's really c like code.
Now you'll notice what happened?
When I got rid of that, you'll notice that red dot that came right up here.
That means that whatever changes I've made to this file, I have not saved.
So we can save what we've done by just going to file, save file or control S
on Windows.
It's really important that we always save before we try to build and run anything.
So in this case, let's start writing a real simple Hello World program.
First thing we're going to do is pound include
and we're going to say io stream
inside angle brackets.
Then I'm going to type using namespace
std followed by a semicolon.
At this point, just type along and follow along,
all this is going to be explained in the course.
And now, we need to write a main function.
This is the place where our program is going to begin executing,
so we're going to type in int space, main,
left paren, right paren,
then we're going to have a left curly brace.
And you'll notice when I pressed enter CodeLite automatically closed that for me.
So it's using those smart braces, which is really, really handy.
And in here, all we're going to say is c out,
two less than signs or left angle brackets
side by side with no space between them.
Make sure there is a space between c out and those angle brackets.
Then again, another space.
And then, I'm going to type Hello World
in double quotes, just like that.
Then I'm going to follow that with two more
left angle brackets or two less than signs,
followed by the word endl,
not end1, but endl.
Now, you'll notice as I was typing,
CodeLite was helping me, it's got code completion.
So it's helping me and I'm just going to indent this so it all lines up nicely.
It's trying to figure out, what I want to type next
and helping me out so I could just press tab and I don't have to type it all in.
So in this case, we have one more statement to write, it's going to be return.
And you can see, when I type ret, it's giving me the return.
So I could just press tab and it'll finish it for me, return zero,
with a space between the return of the zero and a semicolon.
That's it.
This is our first program.
Why do we write a Hello World program?
Well, it's become the norm and the reason we do it is,
if we see Hello World display when we run this,
we know that our development environment has been set up correctly
and it's a pretty easy way to do it. Now you'll notice I am still red here.
So, I want to press CTRL S or file save.
I'm going to press CTRL S and that has now changed to that little X there.
Now you'll notice these red arrows popping up.
Don't worry about those, those will go away in a second when we do the build.
But before we do the build, we need to configure our compiler.
So, what we can do is?
Remember, it's possible that we have a lot of projects in here.
There's only going to be one active project at a time and that's the one that's
bold and italicized, and there's only one right now but you can see it right here.
You can always right click on that and make it active.
And by double clicking on it, you can choose which project you want to build.
Again, we can have 20, 30 projects,
we just double click them, that's the one we want.
So let's configure this project.
So make sure that you've selected Project One.
Then I'm going to come up to this wrench icon right here
that gives us our project settings.
You can also right click
and come down to settings, you can see the wrench icon there.
So again, I'm going to just click that icon.
And now, we get this project settings menu.
I know this looks like a lot to do right now
and it is in a sense but in a while, we won't have
to do any of this because we're going to create a template project
that we can create new projects from and I'll do that in a couple of videos from now
which makes it really easy to do.
So, what do we have here?
These are some of the options that I selected in that new Project wizard.
There's the CodeLite Make File Generator, the MinGW.
So what we want to do here is?
We want to make one change to this.
We want to delete
the working directory right here,
the whole thing, I just want to delete it all
and I want to type in dollar and then
left parent, Project
Path right parent, just like that.
So, you should have a dollar sign, a left paren,
Project Path and a right closing parenthesis.
Make sure that the two P's in Project Path are capitalized.
That's it.
We press tab and you can see it light up like that, I'm going to apply
and I'm going to select OK.
Okay now that basically set up our environment.
Now what we want to do is?
We want to set up the compiler option.
So again, I didn't have to leave that one with okay, but you could just open it again.
And now, we're going to select the compiler right up here
and you can see I've got a C++ compiler and a C compiler,
we're only working with a C++ compiler, so I want to set some options for that.
You can see there's already a few options set here,
gdwarf and a capital O and a wall and I'll let explain
as the course goes on.
So click here
and you'll see these three little dots that pop up right here in a button.
So we're going to select that and now,
we've got a whole bunch of options that we can select from.
We're only going to select one more and that's that one right here.
Enable C++ 17 features,
there's two of them, but make sure you select the one that says dash
std equals C++ 17.
And you can see down here in the command line,
those are the commands that are going to be used by the compiler to build the program.
Now, I'm going to select OK, apply, OK, now we're done.
Now what we can do is?
We can build and run this program.
So how do we do that?
Make sure that your project, you want to run is the active project.
Again, in this case, there's only one project we can come up to build,
we can do a build.
There's a lot of options here that I'll explain as we go.
But we can select rebuild project
and we get the output window come up down here, let me just move this up a little bit.
This is the build output right here
and you can see that it successfully has created a program
which is pretty cool.
Now, what we can do is? We can run this program.
So, let me close that and I'm going to select
Build run
it's going to ask me, you want to build it and execute it or just execute it?
I just want to execute it because I've already built it.
A window pops up and it says Hello World.
This tells you that your build environment is set up,
your compiler is set up, everything's working, everything looks good.
Now, all we displayed was Hello World.
The rest of this stuff is displayed by CodeLite.
It tells you that your program exited with an exit code of zero, that is a good thing.
An exit code of zero means that your program ran successfully.
That's basically what we're returning that zero right here for.
And again, we'll explain all this as we go. Right now, we're just trying to get the environment set up.
We're displaying Hello World, we're returning that zero,
everything worked, there was no other error.
How much time did the program take to run?
There you see it, and then it says press any key to continue and if I press Enter,
the window goes away.
So that's it. We've built our first program, it was pretty easy I think.
It's just a matter of setting these little steps up,
so let me create another project
and I'm going to use this same source code.
And I'm just going to copy that so I don't have to type it in again, I'm just using CTRL C.
And I can close this window down here just to reduce some of the clutter.
So what do I want to do now?
Well, I want to click on the workspace, right click, New project.
And my project name is Project Two.
I'm going to remember the life setting, so it's a console-based program.
It's simple, executable MinGW,
the GNU debugger and CodeLite make file generator.
I'll select OK.
Once that's done, I've got my main.
And notice I've got two mains now, right?
Project One has a main, which is this one.
And project Two has a main, which is this one.
So I'm just going to get rid of this and copy what I did,
I'm going to say Hello World, from Project Two,
like that.
Notice that's red up here, so I want to save it.
You'll notice Project One is the active project,
you see how it's bold and italicized, I can just double click on Project Two.
And now Project Two is the one that's bold and italicized right there,
so it's the active project.
So when I build and run Project Two is the one that's going to be affected.
So, I'm going to click the wrench again
and I'm going to go up to my general options,
I'm going to get rid of this.
And again, like I said, we're not going to have to do this every time,
but we're just going to do it this time, I'm going to create Project Path.
Be really careful here, I didn't put a capital P and it must be a capital P,
just like that.
Then I'm going to compiler
and I'm going to come right over here and I'm going to add these to equal C++ 17,
just like that.
You might want to select the linker and type dash static,
that's up to you.
I would recommend you do so because it's going to avoid
problems with finding DLLs and windows and so forth.
So all you have to do is just click on the linker options and type
dash static or hyphen static.
All one word, no spaces, we'll click apply, we'll click OK,
and that's it, we're ready to build.
So now, I'm going to go to build,
rebuild Project,
there we go.
We have a clean build, and if we run,
it's going to say hello from Project Two.
And that's exactly what we see here, Hello World from Project Two.
Pretty good.
All right.
So, if you have build errors, it's possible.
We get build errors every day, right? So here's an example.
I spelled this wrong.
Instead of io stream, I wrote io steam.
And now, these red arrows are coming back up saying iosteam file not
found and so forth.
So these things kind of help you before we build, to let us know something's not right.
But if I do try to build my project,
you see I'm going to get errors here.
It's going to go io steam, and it's going to say no such file or directory,
it's kind of telling you something's not right.
And we've got an error message down here, the build ended with errors.
So when that happens, we know we've got a problem.
If you run into things like this, they're usually pretty easy fixes,
a lot of times it's just typos, right?
So if I put that back in and build, we'll be good to go.
But if you post something on the Q&A about it and I'll say,
rebuild your project and show me the build output, this is what I want to see down here.
So, we've got several tabs here.
So, you would just click the build tab
and copy and paste all this stuff or give me a screenshot and I can really help you with that.
Similarly, if we let me close this, we get a new one.
If I forgot that semicolon, semicolons are really important.
You can see that little red arrow is popping up saying,
hey, I expected a semicolon somewhere, right after here.
But if I do build, again,
I'm going to get an error right there, it's pointing at it, it says, hey,
I'm expecting a semicolon.
We can't run our program until we get a clean build
so I can put the semicolon back in.
And as you can imagine, there's a lot of places to make mistakes, right?
I spell main wrong, I forget one of these quotes here,
we have to close them up a whole bunch of places,
I forget this closing curly.
So there are a lot of places where things can go wrong.
But once you have this environment set up and you've got a build,
we're good to go, we can proceed and we can write code in the course.
Now, the last thing I'd like you to do is come up to settings,
preferences and come over here to where it says miscellaneous
and it says check for new version on startup and just unclick that,
otherwise it's going to really pester you a lot saying, hey, there's a new version of codeLite out there.
Resist the urge to download and install new versions.
New versions often come with bugs, often come with a lot of changes.
Once you have your development environment set up for this course,
just leave it alone.
Use it that way for the whole course and you're not going to have it any trouble.
Don't just keep updating at every point release because that's
just asking for trouble and for misconfiguration errors.
Okay, so I'm going to click apply and okay,
and we're pretty much done.
So if you've gotten this far and you've got your build system all set up,
congratulations, we're good to go.
Next step is to head over to the
video where I'm going to show you how to set up a project template
so that you don't have to go through all the stuff that I just
went through, we only have to do it once.
And then from that point forward, we just create a new project
based on an existing project
and all this project path and all of this compiler stuff and all of this
linker stuff is going to be done for us automatically,
so we don't have to do that again.
All right, so I'll see you in that video.