‫Hello and welcome.
‫And in this lecture we are going to build a cross compiler.
‫We're not actually going to program it.
‫We're just going to compile the GCP compiler so that we can actually create our operating system in
‫the C programming language.
‫So we can't use DCC because it's targeted for Linux, right?
‫This is the problem.
‫So we create what's known as a cross compiler.
‫So we go to the Firefox browser,
‫go to Google OEs dev cross compiler.
‫I'm just going to show you this article.
‫So again, OS devs fantastic resource as I've already said.
‫So these are the guys.
‫This is the guide to installing this.
‫We're going to need to install some dependencies first.
‫So it needs build essential.
‫It needs python flex.
‫This one, this one, this one and all of these.
‫So we're going to install those now.
‫So let's open up terminal.
‫I'm using Debian.
‫If you're using another version of Linux, you have to do it differently.
‫However, I advise you follow this course on Debian going forward.
‫Um, but that's up to you.
‫If you run into problems and you're using something else, I won't be able to help you.
‫Okay.
‫So we're going to go sudo apt install build essential.
‫So install build essential now here.
‫So flex and Bizon are tools you can use to build lexis and parses.
‫Hence why the you know, we needed one compiler in the C programming language because they rely on these
‫dependencies.
‫Okay, so it's gonna take a while to install those things.
‫We're going to go for bison next.
‫Now we'll go for Flex.
‫And we just go through all of these and install them all.
‫And if you try to install something like this and it says it's not available, don't worry, just carry
‫on installing the rest.
‫Okay.
‫So we now need to download the source code for bein utilities and for CC.
‫That's what we now need to do.
‫So we're going to get bin utils first.
‫And we're going to scroll down and you'll see this FTP link the current release can be downloaded from
‫and then here.
‫So we click that and we're going to scroll down.
‫And we're going to go for 2.35.
‫Which was released in July.
‫Oh, we're just gonna save that.
‫Let it save.
‫So while that's downloading, I'm going to open up GCSE.
‫And we're going to now download that one.
‫So we're going to go to mirrors.
‫So now it's going to ask you to select a mirror.
‫I'm going to go for the France.
‫If you click it, it probably won't load for you.
‫If you have a new version of Firefox, you either need to download file zilla or you can do the easy
‫way, which is to right click copy link, paste it in here and get rid of the FTP protocol and put HP
‫as instead.
‫So HP as FTP lipsticks file and now just press enter and there we go.
‫We can access it from the browser.
‫So now we're going to go to releases.
‫I'm going to get GCSE 10.2.
‫I suggest you get the same one.
‫Okay.
‫The file we want to choose is dot tar.
‫So just click it.
‫When a press open with major press.
‫Okay that will now download.
‫So let's go back to the guide.
‫Okay, so we're going to go in here now.
‫We're going to extract bin utilities while we're waiting for that to download for GCS download.
‫And we're going to extract it to our home folder.
‫Home folder here.
‫It might take a while.
‫We're going to create a sauce folder inside of our home directory to see.
‫Because if you look at the little script here is CDs into home s RC.
‫It creates a build bin utils directory and then it goes back and tries to run our bin utils configure
‫command.
‫So as a matter of fact, we need to drag our bin utils once it's finished extracting, we need to drag
‫it into the source we just created here.
‫Okay.
‫Excellent.
‫Okay.
‫So what we're gonna do now is we're gonna open a new terminal here, and we're going to paste these
‫X spots into the terminal.
‫And now we're going to run every command inside this this, uh, code field here.
‫So we're going to make directory.
‫You might you might prefer to make a build script for this, but that's up to you.
‫Okay.
‫So once you've, uh, made the directory seed into it, I'm just literally copying the commands here,
‫guys.
‫I'm going to copy and paste this one.
‫And we can see it's complaining because I need to replace X, Y and z with.
‫2.35.
‫Whatever version you've downloaded, you'll have to replace it with the correct numbers.
‫So mine will be 2.35.
‫Yours might be four.
‫Depends when you're watching the video and which one you've downloaded.
‫I press enter.
‫We can see configuring.
‫So created a Makefile.
‫So now we just do make.
‫Now I will build our bin utils.
‫This can take a long time.
‫Okay.
‫So you can expect that to take around 20 minutes.
‫If it takes longer, you know you have a slow machine.
‫Don't worry about it.
‫So after that, we're going to go make install, which is the final command.
‫And there we go.
‫Ben Utilities is now installed correctly.
‫We can't just apt install it because again, we need it.
‫We need to compile it with additional flags to be able to compile our kernel properly.
‫So we now need to do the same for GCC.
‫But before we continue, let's just make sure that we've got our path variables set correctly again.
‫So just paste that in just in case you've opened a new terminal by accident, you know, we don't want
‫any problems like that.
‫And when I was just going to follow the instructions here.
‫So we're going to go CD Home Source.
‫We're going to run this.
‫Okay.
‫That's fine.
‫Make directory.
‫Build GCSE.
‫CD, build GCC, and now we need this command.
‫But we're not ready for this command yet because we need to extract our GCSEs.
‫So open up your archive.
‫And we're going to go extract.
‫I'm going to click on source and we're just going to extract it here so you can see it's extracting.
‫This is going to take at least 5 minutes.
‫So I'm going to speed up the video so we can see it is now extracted so we can now run this command.
‫So copy this command here.
‫We're going to paste it in and we're going to need to change the X, Y and Z to our GC version.
‫Mine's ten .2.0.
‫Again, yours might be a later version.
‫That's okay.
‫You know, if you're watching this six months from now, there will be new versions.
‫So we're going to press enter and that'll configure GCC for us.
‫And GCC is now configured and now we're going to go make all GCC.
‫And some of these make commands will take a long time.
‫We're talking like a couple of hours, especially if you have a especially if you don't have an SD disk.
‫You know, uh, hard, hard drives are slow.
‫Okay, so we've just finished the make all GCC command.
‫Now let's do make all dash target dash lib GCC.
‫We've now successfully built GCSE compiler, our own custom cross compiler.
‫We now need to go make install GCSE.
‫And now finally make install dash target dash slip GCC.
‫And now let's test our new compiler copy and paste this command here.
‫And remember, if your path variables aren't exported, this command won't work.
‫Just bear that in mind.
‫So we press enter and there we go.
‫We can see we now have our own custom cross compiler.
‫My ones version ten .2.0 because that's the one I downloaded.
‫Yours might be something different.
‫So congratulations.
‫Now that we have a cross compiler install, we can start writing our kernel in C.
‫You will notice that a lot of the things available with normal GCC are no longer available to us, such
‫as the standard library, the system standard library.
‫We don't have that anymore.
‫That's exactly what we wanted, because when you write an operating system, there's nothing.
‫There's no F open, there's no F, right?
‫It doesn't exist.
‫You have to write it yourself.