Hello, everyone.
In this video, I'm going to create a default project template that we can use whenever we need to create
a new project.
That way we don't have to go through the steps of setting up compilers and all kinds of stuff.
So I'll show you how that's done and we'll create a couple of projects on the way.
I close the workspace that we had earlier in the previous video, so I'm going to create a brand new
workspace.
So I'm going to select new, create Workspace, select C plus, plus, give the workspace a name.
And again, I'm in the Workspaces directory right off of my home folder, and I'm just going to call
this workspace.
Let's call this workspace two.
Okay?
Make sure that this is checked down here to create the workspace under a separate directory.
I'm going to click.
Okay.
Now, I know I've done this before, but it's good to see it a couple of times.
And that way you get the hang of it.
Now that the workspace has been created, I want to create a project, so I'm going to select new new
project and we'll call this project one.
So we want to change this to project one, and that is a different project.
One because it's under Workspaces two folder.
You'll notice it filled in some information for us, which is pretty cool.
Category is the console.
The type is the simple executable GCC compiler, GCC and whatever version you may have installed, the
new GDB debugger and then the build system which is really important, which is default.
And so we can go ahead and click okay.
So now you'll see our project one is created.
We want to again set the project settings so we can highlight that, we can hit the wrench and you can
see that it has some of the compiler settings that we had before.
We just want to add the ones that we added before.
Right.
So under compiler, we want to go to C compiler settings and we just want to make sure we select C 99
and then we hit okay and then we hit okay.
We also want to make sure for the linker that we add the linker options for static and for the static
linking.
You actually don't need to use the static linking on a mac OS for a mac OS.
You would just leave that blank.
It can cause some build errors.
So then we hit okay.
And that's all we need to add so we can say okay again.
And so now we can see our project one we can see again under the source directory that we have Main.c
and we have our C code, right?
And whenever we edit C code, if we want to change this and say just default project, right, we can
hit control s so we can save and you'll see this go to the save option.
You'll see that we have our main.c here.
We can have many projects in here.
You see that project One is bold.
Code light does allow us to have many projects per workspace and you would just see the current active
project would be bold.
And so we can go up just like we did before.
We can go to build, we can say build project or rebuild project and you'll notice there's no errors.
Again, if you had any errors, you'd have to fix them.
And then we can actually run the project by going to build and run.
And again, we can just say execute.
And this will bring up the terminal, which says Default project hit any key to continue.
And at this point, what we want to do is we want to basically use these projects settings for our other
projects.
Basically it will allow us.
So every time we create a new project, we don't have to go through those steps to add C 99 To add the
static linking option, we can just basically inherit a project settings just like this one.
So how do we do that?
We can actually select the project.
We can right click and we can say save as template.
Again project name, select it and say Save as template.
And this will come up and it will say the project.
Name one.
Probably a better name for this would be just maybe my template and be very careful with the name.
Again, I've been emphasizing this, but don't put a space in here.
Don't put apostrophe no special characters.
You know, typically you just use this code convention with lowercase and uppercase, but no spaces
or anything like that.
Now for the project category, you can kind of really select anything.
It's just going to be where it saves it.
You can select console or whatever.
I'm going to actually put this in user templates.
And then for description, I'm just going to say my default template.
You can put whatever you want in here just so you remember it when you load it up.
So now I can go ahead and select.
Okay.
And that essentially saved a template that we can use later when we create new projects.
So let's at this point go ahead and create a new project.
If we select the workspace again, we can right click and we can say new new project.
And now the key here is in order to use the template, what you want to do is you want to change the
category that you select for category, you want to select user templates.
And once you select user templates, it then asks you for the type and for the type you can select what
you just created.
I named it my template.
So now I select my template and this is going to use all the settings for our previous project Project
one, right?
The standard C 99 and the static linking option if you're on a Linux or Windows operating system.
So now we select Okay.
And what you'll notice is and I forgot to rename the project this time we named it Workspace two for
the project.
I should have been Project one, but you will notice is this is not highlighted.
This project one is still highlighted.
So that means it's the active project.
You would have to actually collect select this workspace two folder and you would have to say, you
know, set this as the active project make active.
You can also double click to make it the active project, but you'll see the bolding goes to that project.
Now you can build, compile and run that project.
You can see that it also created a Main.c folder file with the default code and so forth.
It actually put default project in there.
And we can actually fix the name.
If you if you highlight workspace to and you right click, you can actually change the name again by
just saying rename project.
So we could then say, you know, project two if we made a mistake there and we'll update.
But again, whatever is highlighted in bold, that will be the project that actually gets compiled and
run.
And so this allows us to have many projects and projects are just C binaries.
There are C program C executables and so you can work on many C programs at any given time.
And if we check the settings for Project two, again, if we just select the wrench, you'll notice
that we have the static for the linking option.
And the compiler added the C 99.
So we're reusing the project settings from Project One and we can do this for any new project that we
add.
We can just select user templates and we can select the name of the template that created, in my case,
my project.
And we can always inherit those project settings so we don't always have to add them manually for every
new project that we create.
And there we go.
We can select, create many projects like I mentioned, and just double click them and it will compile
and build different projects.
So if we want to build Project two, we built it, we can then run it and we're again, just an easy
way to avoid those manual configuration changes to create many projects with the same types of settings
and so on to the next video.
Thank you.