In this video, we'll run and configure code light on Mac OS ten.
Now we've already installed the compiler tools and we've installed code light.
So let's run code light, we'll come up to spotlight, search and type code light and double click on
the icon.
We'll allow it to run.
Now the first time that code light runs, a couple of things will happen.
You'll get this small code light window show up and then you'll get a setup wizard.
We can just leave that window smallest.
We'll make it larger in a minute.
It's not really going to get in our way right now.
It's important is that we run this setup wizard.
If the setup wizard does not start, come up to code lights menu and go up to help and then run the
setup wizard and run it manually.
But here in this case, it did pop up.
So let's select next.
Code Light uses a bunch of plug ins to allow support for PHP and Node and other technologies.
We don't really want all that.
We only want the C++ plug ins.
The rest are just going to 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 DCC Clang and across DCC we're going to 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 monarchy 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 want to be sure that you save so we can save the changes we've made
and we can run code light again.
So this time I want to 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 going to select new workspace, and the workspace name could be anything you like.
I'm going to say keep 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 plus plus 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 like.
I'm 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
new debugger, we want to use the LTB 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 Test one and it's got a source
directory and it's got a file there called Main CP.
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, test one 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.
We scroll all the way up and I want to select enable all compiler warnings wall and I want to enable
C++ 14 features.
That's the latest standard.
That's modern C++.
I want to make sure that that's enabled and this guy doesn't come on, but you can see that it is there
something 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.
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 code light 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 going to do is I'm going to 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 going to 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 will 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 you want to do is going to type pound include and we want to put IO stream in angled
brackets and press enter then int space main left and right paren.
Then we want to open up a left curly and you can see that the IDE has closed it for me.
And then what I want to do here is I just want to say STD two colon side by side, no spaces and then
see out the insertion operator, which is two less than sines again together with no spaces and anything
you want to type here as far as.
Hello testing.
We want to type a string inside double quotes and a semicolon at the end, and then next line will be
returned.
Zero.
That's it.
That's the entire program.
When we run this program, what we want to do is we want to 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 will display some buttons and things up here which you might find useful.
I'm not going to do that because 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 ID, you can use those buttons.
That's it.
So I've saved it.
Now I want to run this.
First thing I want to 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 going to clean it and then I'm going to
come back up to build and I'm going to say Run.
Now it's going to 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 going to 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 a simple as that.
Some things could go wrong, though.
Suppose that you forgot the 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 there's just 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 it.
You won't have any problems, but you could have things missing like this quote.
This first quote is missing.
This 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 we 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 code light, we've configured code light and
we're good to go.
Now let's start learning C++.