(bright music)
(logo whooshing)
(keyboard clacking)
Instructor: In this video, we'll run
and configure CodeLite on Mac OS X.
Now we've already installed the compiler tools,
and we've installed CodeLite.
So let's run CodeLite.
We'll come up to Spotlight search and type CodeLite,
and double-click on the icon.
We'll allow it to run.
Now the first time that CodeLite runs,
a couple of things will happen.
You'll get this small CodeLite window show up,
and then you'll get a setup wizard.
We can just leave that window small,
we'll make it larger in a minute.
It's not really gonna get in our way right now.
What's important is that we run this setup wizard.
If the setup wizard does not start, come up
to CodeLite's menu and go up to help,
and then run the setup wizard and run it manually.
Okay, but here in this case it did pop up.
So let's select next.
CodeLite uses a bunch of plugins to allow support
for PHP and Node and other technologies.
We don't really want all that.
We only want the C++ plugins.
The rest are just gonna clutter up our interface.
So what we can do here is we can press clear
and then just toggle the C++ plugins.
That way only some of these will show up,
which is exactly what we want.
We just want to concentrate on C++.
Select next.
Now we can scan our computer for any installed compilers.
We can press this button here,
and you can see it's found GCC, Clang, and the Cross GCC.
We're gonna use GCC.
They're really the same,
but we'll use GCC here, and press next.
Now the customization of the theme is really up to you.
This is your personal preference.
The Monokai dark theme is real nice and easy on the eyes,
but it doesn't show up too well on video.
So I'm going to select the Classic Eclipse theme,
and select next.
We'll keep these defaults and press finish.
Now what we can do here is we can say save and exit.
You wanna be sure that you save,
so we can save the changes we've made,
and we can run CodeLite again.
Okay, so this time I'm gonna make this window
nice and big.
And we've got a couple of options
that we still need to configure.
But before we do that, we need to create a workspace.
You can create a workspace by clicking this button here,
or by coming up to file, new workspace.
Either place works fine.
A workplace is just an area
where we can have our C++ projects.
So we can have multiple projects in a workspace.
So I'm gonna select new workspace,
and the workspace name could be anything you like.
I'm gonna say CPP workspace.
Don't use any spaces here, just keep it all together.
And I want to create the workspace
under a separate directory so I can keep my files organized.
I'll select okay, and you can see
that it's created the workspace over here on the left pane.
Now we need to create a C++ project.
So you can right click on that, and select new project,
or you can select the workspace,
and then come up to file, new project.
Either way.
Now we've got some options.
We're going to create console project,
and simple executable g++ right here.
And that's the compiler we're going to use.
And we'll select next, the project name.
Again, don't use any spaces here.
Just create your name,
the name for your project, whatever you'd like.
Again, I'm going to create a separate directory
for each project, and I'll select next.
As far as the compiler, we want to use the GCC compiler
but the debugger, we don't want to use the GNU debugger,
we want to use the LLDB debugger, that's the Apple debugger.
We'll select finish.
And you can see over here on the left
that we've created a project called Test1,
and it's got a source directory,
and it's got a file there called main cpp.
Now, before we run that file,
there's a couple of things that we need to set up.
First click on the project.
In this case Test1, right click,
and then come down to settings and select that.
Then down here toward the bottom
where you see global settings,
come up to compiler options and select the right side.
And then you'll see this little button right here
with the three dots.
Select that.
And what we want to do here is
we want to check a couple of options.
I'm gonna scroll all the way up,
and I wanna select enable all compiler warnings, Wall,
and I wanna enable C++ 14 features.
That's the latest standard, that's modern C++.
Wanna make sure that that's enabled.
And this guy doesn't come on,
but you can see that it is there.
Sometimes it doesn't check on.
You can see that the command line is correct.
So just click okay, I'll apply and click okay.
Perfect.
Now go to the workspace, select it,
right click on it, and come down to workspace settings.
And you'll see we have environment and code completion.
Select code completion,
and check the enable C++ 14 standard.
Okay.
The integrated development environments use code completion.
They try to figure out what you're typing
and what you want to do and where you want to go,
and really help you out with suggestions.
In this case, we're simply telling CodeLite to use
the C++ 14 standard for those suggestions.
I'll click okay, and that's it for the setup.
Now let's modify this C++ file and run it.
Let's double-click on that.
And that font is really small,
so what I'm gonna do is, I'm gonna make it a little larger
so it shows up better on the video.
Most likely you won't have to touch it at all,
but I'm just gonna come to settings, colors, and fonts,
and I'll set the font to let's say 18.
And I'll apply that, and that should be much more readable.
Okay, so now let's modify this file.
This is actually C code, not C++ code.
So let's get rid of all this,
and we'll type a simple C++ program
that'll test our installation.
During this course, I will go in detail
through the anatomy of a C++ program.
And everything that I'll be typing here will be explained.
But for now, just follow along,
type along, to make sure we've got a clean install.
So the first thing we wanna do is
we wanna type #include, and we wanna put
iostream in angle brackets, and press enter.
Then int space main, left paren, right paren.
Then we wanna open up a left curly.
And you can see that the IDE has closed it for me.
And then what I wanna do here is I just
wanna say std, two colons, side by side, no spaces,
and then see cout, the insertion operator,
which is two less than signs.
Again, together with no spaces,
and anything you want to type here as far as
hello testing, we wanna type a string inside double quotes
and a semicolon at the end.
And then next line will be return 0.
That's it.
That's the entire program.
When we run this program, what we want to do is
we wanna display hello testing to the console.
That's all it's going to do.
I'll save this under save file.
At this point on your end, you may want to do view,
toggle minimal view, and that'll display,
let me do that again.
That'll display some buttons and things up here
which you might find useful.
I'm not gonna do that 'cause it clutters up the screen,
and I don't want any distractions
when I'm teaching the class.
So I'll toggle that away.
And what I'll do is, rather than click on the buttons,
I'll be really explicit as to let's click on build,
run build, clean, and so forth.
That way you can see exactly what's going on.
Once you get familiar with the IDE,
you can use those buttons.
That's it.
So I've saved it.
Now I wanna run this.
First thing I wanna do is I want to go to build,
and clean the project.
When we clean a project, we're basically just wiping
out everything that's been done in the past,
except the source code.
So the project is in a state that's ready to go.
So I'm just gonna clean it.
And then I'm gonna come back up to build,
and I'm going to say run.
Now it's gonna give me an option that says
would you like to build the active project
before executing it?
Of course I do, because I haven't built it yet in this case.
So I'm gonna select build and execute,
and that will compile the program and open up a window.
And there's the output right there.
Hello, testing.
So this terminal window is running the program
that I just wrote.
That's it.
It's as simple as that.
Some things could go wrong though.
Suppose that you forgot this semicolon here,
and I'll save it and then I'll do the same.
I'll do run, build, and execute.
And you can see if I move this window just slightly up,
you can see that I've got a compiler error.
And this is what compiler errors look like.
You see the red text here,
and it says error, expected a semicolon after an expression.
Also, you'll see that little red arrow right here
telling you that there's something wrong here.
And basically what you need to do is put a semicolon there.
Just type the program really carefully, exactly like I did.
You won't have any problems,
but you know, you could have things missing,
like this quote might, this first quote is missing,
you might have three less than signs.
There's all kinds of little things
that could go wrong with the program,
but if you just be very careful, type it in, save it,
and come back up to build and run, build and execute.
And you can click on there if you like.
That way you don't have to keep doing it all the time.
And there's the run.
That's it.
We're all set on Mac.
We've installed the command line tools,
we've installed CodeLite, we've configured CodeLite,
and we're good to go.
Now let's start learning C++.