Welcome back. In this video we're going to configure CodeLite
to run on MacOS 10.
Now I'm running MacOS 10 Catalina,
and I'm installing CodeLite 14.0.0 in this case.
Before we do this, we've got to be sure that the compiler
and CodeLite have been downloaded and installed.
I did that in the previous videos. If you haven't done that please go back and do that.
So again I've installed the compiler and CodeLite.
Now I'm going to run CodeLite for the first time.
You can come up to spotlight search and type CodeLite,
and you can see CodeLite shows up right here version 14.0.0.
And I'm going to double click that to run it.
Now this is pretty normal.
You may or may not get this error message here.
This is very common when you're installing software from the internet that's not
coming from the Apple app store.
It says the CodeLite can't be opened because the developer cannot be verified.
So what does that mean? That just means that you have to allow it to run.
Okay. It's a security feature. So what we're going to do is we're going to cancel here.
And again, you may not get that message.
It all depends on how your system has been set up.
Come up to the Apple, and go to system preferences,
and then you're going to select security and privacy right here let me move this to the center here.
I'm going to select security and privacy,
and then in the first tab, the general tab,
you can see right down here it says CodeLite was blocked from use
because it's not from an identified developer.
Again, all that means is that this app didn't come from the app store.
It came from the internet. So I'm going to select open anyway,
and that will run CodeLite.
And again, now you can see I get the same message, but now I get the open button.
So I'm going to click the open button, and let me close this system preferences
and that's going to run CodeLite for the first time.
And this is what you get the first time you run CodeLite.
Now there's a lot going on here.
I've got a workspace view over here.
I've got a welcome window and it looks like a wizard, it wants to run a setup wizard.
And I also have this message down here that says CodeLite now offers
a better editor color theme. So again, there's a lot going on.
You may or may not get this message down at the bottom about the color theme.
If you do, then what I'd like you to do is cancel the wizard.
We'll run it manually in a moment,
and say yes to this fix.
So I'm going to select Yes right down here on the bottom right, I'm going to click Yes.
And it says a CodeLite restart is needed.
Would you like to restart it now? I'm going to say yes again.
Now CodeLite will close down and restart,
and it should be back in a second. Okay, perfect.
Now what we need to do is we need to run the wizard, the setup wizard.
That's the one we canceled a second ago. So let's run it manually.
We come up to help, run the setup wizard.
Okay, I'll do that again. I'm going to select help, run the setup wizard.
Now it's important that we do this. We only have to do this one time, right now, that's it.
Once this is done, we don't have to do it again.
So welcome to the setup wizard. I'm going to select next.
What's my development profile. In other words,
what kind of development am I going to be doing with CodeLite?
Well, I'm going to be doing cc++ development.
CodeLite supports PHP, JavaScript,
node, I believe. I'm just going to select cc++ development
because that's what this course is about, and select next.
Now this is a really important step. Remember, we've already installed our compilers.
So we're going to let CodeLite set up those compilers for us.
So we're going to click on the scan,
and CodeLite will scan our system for those compilers.
So I'm going to select that now,
and you can see that three compilers show up.
Now that's pretty normal. It's really the same compiler with three different names.
So this is exactly what we want. If nothing comes up here
then it's very likely that you didn't install the compiler.
So go back to the previous videos and install your compiler.
I'll select next. Here you can customize your colors.
I'm just using the defaults here.
The dark, the light, the gray, whatever you prefer.
Again, I'm just selecting the default.
I'll select next.
For white space and indentation,
I'm just going to leave these defaults as they are, and I'm going to select finish.
Now we're done. CodeLite's going to close up and open up again.
And our compilers and our environment should be set up.
First thing, we need to verify that
the compilers were indeed set up correctly.
So we can do that by coming up to settings,
build settings
and then you can see right here under the compilers tab when you select
GCC. We're going to use GCC.
Now the important thing is that when you select GCC and compilers
and then tools, you see stuff here. We see those paths here.
If there's nothing here then again
most likely something went wrong with your compiler installation.
Okay. So that's it. I'm going to select okay,
and our compiler is set up.
Okay. So CodeLite,
as I mentioned, is an integrated development environment,
which means that we can build and run and debug
our c++ programs. It uses a workspace model.
So the idea is that we can create a workspace,
and we create workspaces on this left side here. You can see workspace view up here.
And then we can add multiple projects to a workspace.
Now that's pretty cool.
We can have one workspace, and a whole bunch of different c++ projects within it.
A lot of other IDEs don't work that way.
They basically just allow you to work on one thing at a time.
So this is a pretty nice model here.
Now in order to do that, we need to create a new workspace, right?
There's nothing here. You can see there's a lot of space here, right?
There's nothing going on. So what we're going to do is we're going to create a new workspace.
We can do that by clicking right here on this button.
New workspace or I can come up to appear in the menu bar and click workspace,
new workspace. Again, I could use either one.
I'm going to select this button right here.
And then I get this select workspace type dialog box.
I want to create a c++ workspace.
It's really important that we choose c++ here, and I'll select okay.
Now it's going to ask me where do you want to store this workspace? I'm just going to put it right
in my user directory's,
documents directory or documents folder.
And what's my workspace name?
I'm just going to call it FirstWorkspace.
Here it shows you the complete path to where this file
FirstWorkspace.workspace is going to be stored.
If you want to put it somewhere else, you can just click these three buttons and choose whatever folder you like.
I would encourage you to select that little checkbox down here that way it creates
the workspace in a separate directory
that when we create multiple workspaces they'll be nicely organized.
Now word of warning. Do not use spaces,
special characters.
In other words, don't use spaces like this here,
don't use special characters like
pluses and ampersands and all kinds of weird things.
And don't use any international characters either.
Those will cause all kinds of build issues.
Keep the naming really, really straightforward with everything we do in CodeLite.
Also, if your username,
you can see my username right here is my first name and last name.
If your username has spaces or if it has special characters
or international characters,
then put your workspace somewhere else.
Create a new folder somewhere that doesn't have that
and just store it somewhere else or off your root directory.
We're good to go here. We're going to create the workspace.
Now when I click okay, you're going to see this workspace.
FirstWorkspace appear right up here in the workspace view up in the top left.
So I'm going to click okay,
and here's my workspace. You can see it right there FirstWorkspace.
You can see this whole area here on the right has been
cleared out.
In and of itself the workspace really doesn't do much for us.
It's really a container or a holder for projects.
So what we need to do now is to create our first project,
and we can do that by selecting the workspace and then right clicking on it
and selecting new, new project. Okay.
So I'll do that again. We're going to right click on the workspace,
and then select new, new project.
And now we're going to get a new project wizard.
And this is really important that we get this right.
There's a lot of settings here.
And depending on how we fill them out our projects may or may not build.
So I'll go through this really slowly and carefully.
This is the path to our workspace.
And it's asking us for a new project name right here.
So I'm just going to call this project1.
Again, no spaces, no special characters, no international characters.
Make sure that this checkbox is checked.
Create the project in its own folder under that workspace,
that keeps them nicely organized.
The category, we're going to select console.
The type, we're going to select simple,
executable g++, right there you can see simple
executable g++. Don't choose anything else.
The compiler, we're going to use is GCC.
And the debugger, we're going to use is different from the ones that we use on windows
or ubuntu Linux.
Those of you who are using multiple operating systems,
we're going to use the LLDB debugger, that's Apple's debugger.
And then the last thing and this is probably the most important one is the build system.
We want to be sure that we select default.
Okay, default.
So I'll leave this screen up for a second. You can pause the video,
and I'm going to go through this one more time while you do that.
We've got our workspace up here. We've got the name of our project that we're going to create.
Again, no spaces. No special characters. No international characters.
You're probably tired of hearing that, but it's really important because the majority of build
errors that I see in the QA forums is because students put
really strange characters and there are spaces, so don't do that.
Make sure that this checkbox is checked. The category is console.
The type is simple executable g++.
The compiler is GCC.
The debugger is the Apple debugger LLDB. And finally,
the most important on the build system is default.
When I click okay, you'll see a project
created over here under the workspace, called project1.
And I put a special character in there by accident that would have been not good.
So let me select okay.
And here you go. There's the project, project1.
You can expand these or contract them by selecting the chevron.
You can see project1 has a source folder in there,
and that source folder has a main CPP file.
That's our source code.
That's what we're going to type our programs into.
Now I can't see it over here because I haven't selected it.
So I'm just going to double click main.cpp.
And now you can see the source code.
Now this is c source code, not c++ source code.
So we're going to change this in a minute. And we're going to write our own.
But it's important that you be able to see this here. So double click on main CPP and
that's what you're going to see. Now
this font is a little bit small.
So what I'm going to do is I'm going to make it larger.
You don't have to do this on your end because it's probably fine for you but I think a
bigger font will be easier for you to see on video.
So I'm going to select the font.
And I'm just going to make it size, let's make it 18,
so you can really see it. I'll select okay, apply okay
and that should be a little bit better I think.
Okay so now what we're going to do is we're going to write our very first c++ program.
So I'm going to delete all of this stuff right here.
And I know you're going to have some questions as I type this.
Just type along, follow along.
All this will be explained in the course.
The importance of this video is to be sure that you can build c++ programs.
So again, type along, follow along. All this is going to be explained.
So the first thing we're going to type is #include,
followed by a space and then followed by iostream
in angle brackets, and I'm going to press enter.
Now the pound is the hashtag. We call it pound in c++.
So again, pound includes space
iostream in angle brackets or less than greater than sign in the end. Okay.
Now we're going to type our main function. So I'm going to type int,
followed by a space, followed by the word main,
followed by a left parenthesis a space and a right parenthesis.
Now we're going to type in left curly brace.
And I'm going to press enter.
Now you'll notice that the IDE automatically put the curly that closes,
the right closing curly brace. So I'll do that again.
I'll put in a left one, press enter. You can see it's closed it for me.
That's one of the nice things that IDEs do.
Now what we're going to do is we're going to type a couple lines of code and that's it. We're going to type
STD, followed by two colons,
followed by cout.
Okay so std::cout then a space, followed by
two less than signs, no space between them
and then we're going to type Hello Testing
inside double quotes,
just like that then another space,
two more less than signs, and we're going to type std
endl,
and a semicolon at the end
and then return zero on the next line, followed by a semicolon.
That's our program.
So again, pounded include iostream in angle brackets.
Int main with two parentheses there, open one and a closed one.
The curly brace std
::cout,
two less than signs, hello testing and quotes,
two less than signs,
std::end;
and return zero. It's a lot harder to say than it is to write.
Make sure you've got semicolons on the ends of these lines.
And what does this do? Well we're, including the iostream library,
so that we can do input output. In this case, we're only going to do output.
And what we're doing here in this function is we're displaying Hello Testing
to the console. That's it. And we're putting a new line at the end to go to the next line.
Okay. We're returning zero because main always returns zero,
and we'll get to all of this in the class as they say stay tuned more is coming.
Now one of the things that we need to do is we need to save this before we build it and run it.
So notice it over here, you see that red bar going between the
one and the six right there.That's telling you that you haven't saved this.
So how do you save it, you can come up to file, save file.
Now you'll notice save file is grayed out.
This is a bug in this version of CodeLite,
but the command works. The command s works,
which is what I'm going to use. So what I'm going to do is I'm going to press command
s to save this.
And you'll notice that this red line will turn green.
So I'm going to do that right now I'm going to press command s.
Notice it's green now that's because I just saved it.
That's really important that you save it.
So our program is written, and we're almost ready to run it.
We just need to make a couple of changes to the project.
And we'll do that right now. We'll click
on the project name right over here in the workspace view.
And I'm going to right click it
and then come all the way to the bottom of these options and select settings.
And now I'm going to get a settings screen for my project.
Over here, it says general and we don't have to change any of this stuff.
This is the stuff that we -- that automatically got set up for us
when we created the project in the project wizard.
But what we do want to do is we want to click compiler here.
And we want to make a couple of changes to the compiler.
So we're going to click compiler, and go up to c++ compiler options
right here.
And I'm going to click right over here on the right.
And you'll notice this button with the three dots shows up right here.
Click on that and what we want to do here is
I'm going to scroll all the way up here.
And I want to be sure that I've selected c++ 17,
right here, enable c++ 17.That's important.
So I've selected that. Up at the top I want to enable all compiler warnings.
I've selected that. You can see as I click these,
and that's a little bug there too huh it doesn't show up.
Well, as I click these, you can see the commands down here,
right. In the command line, you can see the switches.
So there's really four things we want. We want to see the w all down here.
We want to enable c++ 17 down here, you can see it right there.
And there's two more. One is optimize for debugging,
and the other is produce debugging information. Those are the four
that we want to have enabled.
Once we've got those enabled,
we'll click okay. Apply and then okay.
So our program is done. Our project is set up.
Now you may think, Wow do I have to do these steps every time I create a project?
Yes, but we'll create a project template in a couple of videos
from now that way you can create the one template.
Create projects from it, you don't have to do this ever again.
So at this point, we want to come up to build
and then build and run the project.
What that's going to do is it's going to compile the project and run it.
So let's do that right now.
And if we don't have any errors, our project will run.
Hopefully, I didn't have any typos. I'm going to select that,
and our program is running.
This is what pops up. This is a terminal window.
And you can see this last login information.
I'll show you another option for a Mac that can come in handy.
But you can see right here is the important part, Hello Testing.
That's exactly what our program did. You can see the Hello Testing up here.
Hit any key to continue. I'll just press any key
that goes away,and our program is done. Everything worked correctly.
Now down here is the output view.
And there's two important tabs here.
The first one is this one, the output tab.
Now this doesn't show you the output of the program.
It shows you the output of when we ran the program of how it's being run.
So this working directory here. This is important because sometimes
it'll help us understand
when we're having problems. Something won't run correctly. We can look here.
The other important tab is this build tab. Now this one's much more important.
This tells us what happened during the build of our project.
You can see that I'm running the compiler here g++.
You can see the file that it's running it on, main CPP.
You can see those options we set up and so forth.
Zero errors, zero warnings. That's good.
What could go wrong
and where do errors show up? Well, the errors would show up right down here.
So suppose that I forgot that semicolon right there,
and notice that this is red right here now and the rest is green.
So I have made a change. I need to save. So I can press command s.
And I just saved it. It's all green now.
And now I've come up to build, build and run.
It's going to give me an error because I forgot that semicolon.
So I'm going to run it and you could see down here
that the build ended with errors. Do I want to continue? Well, no. I don't want to continue.
I want to fix my errors.
So in this case, you can see the red text right here, it says expected semicolon.
And if you click on that red text,
this little red arrow pops up here and kind of tells you it helps you out. It's like something's not
right here. Between the error code and the arrow up here,
you can kind of tell what's going on, right. So I'm going to press the
put the semicolon back in, save again.
So you got red here so I'm going to save again,
and I can build and run and it should build and run just fine.
Now common errors that I see in this first program
for getting semicolons is very common.
Some students if when you see these left parent,
right parent, sometimes that looks let me --
put a couple extra ones there. Sometimes that looks like a zero.
So students type main zero and that's incorrect.
It has to be a left parent followed by a right parent.
And the other thing I see is this word up here gets misspelled a lot
it's iostream. It's not iosteam. It's iostream
with an r but often that happens.
I guess, we're used to writing steam and not stream. So I'm going to change that to stream.
I'm going to save. And when I run the program again, it'll run just fine.
I don't particularly like the terminal window that you just saw.
I like to change that in CodeLite. So I like to come up to in - on Mac.
I like to come up to CodeLite preferences here.
And then down at the bottom of the preferences, you'll see terminal.
And right now the default is Terminal. That's the one you just saw.
You can choose iTerm 2 or CodeLite terminal. I tend to like codelite terminal.
So I'm going to select that and I'll run it so you can see
how what it looks like in this terminal.
The problem with using Terminal
is that sometimes you get a whole bunch of terminals. It doesn't tend to close correctly all the time.
So I'm going to select CodeLite terminal, apply
select okay.
And now when I run, I'm going to build and run a project again.
You can see what the CodeLite terminal looks like.
Now it says it needs access to my documents folder.
I'm going to allow it and you only have to do that once, there you go. Hello Testing!
Hit any key to continue.
This to me this looks a lot cleaner than the other terminal it has a lot of stuff in it.
But it's your choice. You can use whichever one you like. They both work okay. So again I'm going to
press any key. So that's it.
We've written our very first c++ program. We've gotten it to build.
If you have any errors or any issues that are beyond the semicolon and so forth,
you're getting strange error messages.
Post it on the forum,
and you can see here it says it CodeLite restart is needed that's because I changed the setting.
You can just say yes, and I'll say that in a minute.
But on the forum, I might say show me your build output.
And what I want is this part right down here.
So you could just copy and paste this stuff
or you could just give me a screenshot and post it in the QA forum if you have any errors.
And it's really easy to figure it out here for me, and I'll
let you know how to fix it if I can.
If you follow these settings and write this code like this, you should be just fine.
All right. So that wraps up this video.
I'll see you on the next video, and we'll start writing some c++ code.