Hello everyone, welcome back.
In this video, I will create a default project template,
that we can then use to create new projects from.
This makes us so much more productive and a lot less chances for errors as well.
So we're going to create the project, save it as a template,
then when we create new projects, we'll use that template as the base.
So let's get started.
You notice here that I've got the
previous workspace that I was working on in the installation videos.
So let me just create a brand new workspace, I'll go through the flow again
just so that you can see what it's like one more time.
The more you see it, the easier it becomes.
So I'm going to click right here new, create a new workspace.
I'm going to select C++ workspace, click OK.
Then I'm going to put it right inside my users folder,
workspaces folder, I'm going to call this one Workspace2.
Again you can name that anything you like.
Make sure create the workspace under a separate directory is checked,
I'll click OK.
Perfect, so now you can see our workspace has been created.
Now I can right click on the workspace and create a new project.
We can name this project again, whatever we like, so I'll just call it project1.
Make sure that create the project in its own folder is checked.
The category is console,
type is simple executable g++,
the compiler is MinGW,
on Linux and Mac you'll choose GCC for the compiler.
The debugger is the GNU gdb debugger,
on Mac you will choose lldb vs-code
and then we want to select the codelite,
make file generator as the build system.
So I'll select and click OK.
And that's going to create my project,
as you can see in the workspace here with the source folder
and the default main CPP which we are going to remove and write our own.
So let's do that real quick.
Pound include iostream, just like we did before
using, I'll put a space here.
Using namespace standard.
Then we'll create our main function right here.
We'll say cout and what I'm going to do here is I'm going to display
default template.
End line again endl not end1
and we'll return zero.
That's it.
Notice that this is red, so we need to save our project,
I'm going to press CTRL S on Windows or command S on Mac
and we've got just what we had before.
Now before we build this, let's set up our project.
So I'm going to select project 1 and click on that wrench.
In the general tab I want to go to the
working directory right here,
delete that and replace it with project path.
Just like we did before, again uppercase P for Project and Path,
I'll press tab and it'll light up dark like that.
You don't have to change anything else,
in fact don't touch anything else, It's just like it's supposed to be,
we'll click on compiler now, over here on the left,
go to my compiler options
and click those three dots in the button.
And I'm going to select enable C++ 17 features right
there which is the STD equals C++ 17.
I'll click OK, then I can come over to my linker
and if you like you can put a dash static
in the linker options again, dash static, no spaces in there.
Mac users do not do this,
leave that blank, otherwise you're going to get linker errors.
So you can do this for Windows and for Linux, but
Mac users leave it blank, that's it.
I'll apply, I'll press OK.
Now let's make sure that we can build, so we're going to come up here to build,
rebuild project.
We've got a clean build, no errors.
Let's run it to make sure we can run it.
And it should display default template,
It does indeed, so we've got a good build, we've got a good project.
Now what we can do is we can save this project as a template
and we can use it later to create new projects
from it, without having to do all this setting stuff again.
So let's do that, let's right click on the project 1.
And we'll comedown here to where it says save as template,
okay?
Let me do that one more time, right click on project 1, save as template.
The project name I'm just going to call this
default project.
You can call this anything you like.
The project category, this says where am I going to store this?
I'm going to store it in a category called user templates,
It doesn't really matter where you put it as long as you remember where you put it.
So user templates works for me and the description again can be anything.
Just going to say my default project.
There we go, and I'm going to press OK.
Done.
Now what we can do is?
We can create new projects from that template, so let's do that.
I'll click on the workspace, I'll right click, new project.
The project's name could be anything, I'll just say Project 2, again remember,
no spaces, no special characters, no international characters anywhere.
The category now, what we'll do is?
We'll pick user templates
and for type, we'll pick default project which is what we just created.
Double check that, if got MinGW or GCC on Linux and Mac
and the GNU debugger or the lldb vscode on Mac.
They should be populated from the template.
We've got CodeLite make file generators,
you can just give it a once over and make sure everything looks good
and I'll press OK.
Now you can see that Project2 has been created,
however project1 is still the active project.
So we can make Project 2 the active project by just double clicking on it.
And now Project 2, you can see it's italicized in bold.
So let me close this up here
and let's open up our project 2's main CPP.
Notice I got the default template code which I wrote earlier.
If I select project two and I click the wrench,
you can see that in the general, it did not keep the project
path unfortunately.
This is a bug that hopefully will be fixed soon,
so in the mean time, we'll just have to type Project path,
just like that.
But the compiler option did take,
you can see the STD equals C++ 17
and the linker option, you can see the static right here.
So unfortunately, we still have to come in here and type Project Path,
but it's a little bit less work than we had to do before.
Apply, okay
and we're good to go now, we can come over here to Project 2, build it.
And you can see the C++ 17 over here,
you can see the static being used over here, so all this is good
and we can build and run.
And I'll execute it and it should say default template,
just like we did before.
We can obviously change this and I'm going to say hello from Project 2.
I'll save that and I can build and run again.
There's our build,
It's a clean build, always be sure that you don't have any errors here before you run.
I'll execute and hello from Project 2.
So there you go, this makes life a little bit easier,
unfortunately we still have to set that project path right here
for the general options.
But it's a lot less than we had to do before and I think we're good to go here.
So you can use this technique, so that finishes up the
configuration of the default template.
I'll see you in the next videos and we'll start coding.