Hello, everybody.
So we're back.
Let's configure code light to work with the compiler.
Obviously at this point we've already installed the compiler and we've installed code light.
So first step is to open code light so you can come down to your applications.
And if you move over to the next screen here, you'll see code light right here.
If you don't see it there, you've got a lot of applications, just type code or something like that
and we'll find code light.
Then we want to run this.
You can see it's opening up.
And the first time that you run code light, you're going to get this setup wizard.
If you don't get the setup Wizard, you can find the setup Wizard under help and you can run it manually.
So I'm going to select next I'm going to select my default profile, which is C, C plus plus development
and click next.
Now we want to set up our compiler, so we're going to hit the scan button and it should find the compiler
that we just installed.
So I'm going to click scan and there it is.
It's called GCC.
That's the name that we're going to be using for the compiler on Linux.
So we just select next and it will set up the compiler for us.
Customize the colors.
You can use the light theme or the dark theme totally up to you.
I'm just going to stick to this default.
Click next white space and indentation.
I'm going to keep all these defaults and click finish.
At this point, we are done.
It's going to close and open up again automatically.
Okay.
So at this point, we've got a couple of areas.
We've got this area over here on the left, which is the workspace view.
This is where we're going to store all our workspaces and projects.
We've got this area here, which right now is just an area for four big buttons.
This is going to be our editor.
This is where we're going to be able to enter and type in our code.
And then down here, you can see that local workspaces, since this is the first time I've run this,
I haven't opened any workspaces.
But once you start creating workspaces, they'll show up here and you can choose one of your recently
opened ones, which is kind of nice.
Okay, so our first order of business is to create a new workspace.
So like with many modern user interfaces, there's usually three or 4 or 5 ways to do the same thing.
In this case, I could just click here on this big button, create a new workspace.
I can come up to workspace, new workspace, and there's probably other ways to do it as well.
I'm just going to click this big button that says Create a new workspace.
Once I do that, you need to select the type of workspace.
It's going to always be a C plus plus workspace for us and click okay.
Now, what's the workspace path?
I'm going to store this not in documents.
I'm going to create a new folder right off of my home directory, and I'm just going to call it workspaces.
And that's where I'm going to save all of my workspaces.
So now in order to create a new folder, you can come up here and you could do this through the command
line on your terminal as well.
But I'm just going to do it with the interface.
I'm going to select this guy and just type workspaces and create it.
And you can see that it now shows up right where you expect it.
So I want to choose that workspaces and hit open and now what is my workspace name?
Well, this one is called Workspace one or Section one or Section two, whatever you want to call it.
If you're working through the course, you can call it Section three.
Section four.
Section five and create all your projects for that specific section of the course.
Or you can organize in whatever way makes sense to you.
Be sure that you've checked, create the workspace under a separate directory.
That way it'll keep your workspaces nicely organized and I'll click okay.
And now you can see over here in the workspace view that it's created that workspace.
Now we want to create a project.
So again, select the workspace and you can come up here to file create.
I'm just going to right click on the workspace and create a new project.
Now we've got a bunch of options here to set up, which are pretty straightforward.
The first one is what is the name of the project?
Well, I'm going to call this one project one or again, whatever you want.
Something that's very important.
Do not use shared drives here.
Do not use spaces anywhere.
For example, don't say Project one.
Do not use special characters.
Don't do any of that.
Don't use international characters.
Just use simple words with no punctuation, no spaces and no special characters.
This is one of the biggest reasons for builds to fail.
So again, keep the names really, really simple.
So project one, make sure this is checked.
Create the project in its own folder.
The category is a console application.
That's an application that runs in the terminal.
The type is going to be simple executable GCC because we're writing C applications.
So simple executable GCC.
The compiler is going to be GCC 11, the one that you just installed or whatever version it is GCC.
The debugger is going to be the GNU GDB debugger.
And the build system is going to be default and default.
That's really important that you make sure you select your build system for default.
So go ahead and click okay.
So we'll see here that we now have a project, one folder under the workspace, one folder.
We can maximize that and we'll see a source directory and then we'll see main.c.
All C programs end in the dot C extension.
So we can double click this and you'll notice that the editor now brings up the main dot C program with
some code inside of it.
This code is automatically generated by code light.
You don't have to understand this code right now.
Again, I know there's going to probably be a lot of questions about this.
We're going to go through all the details.
This is later.
Right now, we're trying to get our environment set up to be able to build run our programs.
So this code is really important.
You see some curly braces, things like that.
This is our source code.
What you will notice is if you edit this source code, so say we change Hello world to hello testing.
We will notice as this becomes red and that means that the file is not saved.
So you can always save your text, save your source code by hit control s and then you'll see that go
away.
Or you can go up and you hit file and you can say save file.
So now we have to actually just check the project settings to make sure they're okay.
We can highlight our project right here on the left hand side.
We can either go ahead and hit this wrench icon to go to the settings or we can right click and we can
go down to the settings.
This way either way is fine.
So once we hit the wrench, you'll see that the project settings come up and you'll notice a lot of
this is filled in for us.
It's the compiler we chose before and some other things we can keep those as the default.
We want to go to the compiler settings and we want to go to the C compiler options right here and you'll
see there's already some options that are selected for us, the G Dwarf two, that's for debugging the
dash OS for optimization.
The dash w all is turning all the warnings on.
Now we can hit the dot, dot, dot on the right hand side and just see if there's any other options
that we want to enable.
I don't think really the only maybe interesting one enable the C 99 features and you'll see that it's
added down below on the command line.
So you see exactly what we talked about earlier.
And then you see standard C 99, That's probably the only one we're going to need.
Everything else is good for debugging.
If anything's missing from down here, you can just go up ahead and check it and so then we can hit.
Okay, We want to make sure that our linker also has some options.
There's a dot, dot, dot there.
If you select it after you select the text field, if you hit the dot, dot, dot, you can basically
just say static linking.
We just want to say dash static and then hit.
Okay.
And those are all the settings we need to apply.
The debugger should already be set for you, but if it's not, we do want to make sure that we select
the debugger, which is the GDB debugger which was in your user folder.
So you can usually go down to user bin and try to find GDB.
If you just scroll down right here, GDB that's the debugger we want to use.
So we can just point our debugger path here to gdb, make sure everything else is set okay and we can
hit apply and then we can hit.
Okay.
And at this point we want to actually be able to build and run our program so we can build and compile
by again selecting a project.
You can right click and you can say build or you can actually go up to the menu option and you can say
rebuild project build project.
Either one will work.
So once you hit build project, you'll see that there's some output that comes down on the bottom under
the build tab.
And what you see is basically the commands and the options that we just applied in our project settings,
right?
You see the Dwarf two for debugging standard C, 99 dash warnings, all and so forth.
You see that dash static option for linking and you also see most importantly, that there's no errors,
no errors, no warnings.
Now, if you're missing a semicolon or if you were missing a bracket or something like that and you
tried to build.
You would see that there's an error and you'd have to go and you'd have to fix that error.
We'll talk again about syntax for C and a lot of other important options in coding in later lectures.
But you should be able to build successfully by just the templated code that already comes up.
And you should see the output that I just showed you.
Right?
Build project successfully Zero errors.
Now you can actually run your program again.
We can go back up to the build menu option.
We can say run and once we hit run, it's going to come up and it's going to say, Do you want to build
again?
And so forth.
We can.
We just built so we can basically say execute.
We don't need to build again.
So we can just say execute and then that's going to bring up our terminal, right, with the output.
Hello, testing.
So we able to run our program successfully and it says hit any key to continue for the terminal to go
down so we can just go ahead and do that.
And so we're good to go.
Again, you got to watch out for some errors, common errors that you may see if Main is misspelled
or missing a bracket.
But at this point, we compiled we able to run our program successfully.
So our environment is pretty solid.
You will notice the two most important windows here at the bottom, the build and the output.
The output kind of just tells you what's going on in what was currently executing the build is really
the most important thing because it has all your compiler output and if you have any errors will be
listed there.
In the next video, we're going to show you how to set up an actual template so you don't have to provide
all the settings you do for every single project.
You basically can inherit project settings and you don't have to do the standard C, 99 and so forth.
With the static linking, we're really close to starting to write some code, so we're moving right
along.
If you have any questions, please post them in the forum.
Thank you.