WEBVTT

00:01.050 --> 00:05.440
In this lecture I want to broadly go over how our programs get built.

00:05.450 --> 00:08.370
So are able to run.

00:08.410 --> 00:12.780
So there are three main steps that have to happen.

00:13.670 --> 00:17.060
The first step is the preprocessing step.

00:17.060 --> 00:27.240
The next is the compilation and the last step is the what's called blinking so the preprocessor effectively

00:27.510 --> 00:35.790
replaces all the preprocessor Duret preprocessor directives in the program and paste the relevant info

00:35.850 --> 00:37.590
into the files themselves.

00:37.590 --> 00:45.890
So for example we have the line that I didn't cover before which says include IO stream.

00:46.320 --> 00:56.790
So the hash include is actually a directive preprocessor directive that says make sure that IO stream

00:56.790 --> 01:06.070
which is a part of the standard library has all the input and output it'll paste the entirety of IO

01:06.070 --> 01:09.510
stream into our our program.

01:09.550 --> 01:17.650
So that's why we're able to use things like C in and C out and actually output things and get things

01:17.650 --> 01:21.050
from the console.

01:21.070 --> 01:30.090
So after this is done the output of the preprocessor will be C++ files with absolutely no directives

01:30.090 --> 01:34.520
so they'll be here C++ files.

01:34.690 --> 01:43.960
And that goes into the next stage which is the compilation stage and the compilation stage will take

01:44.140 --> 01:54.950
all of the C++ files as input and then turns them into assembly code and then machine code and place

01:54.950 --> 02:03.410
them into these stored object files and U-Mass Why does it need to do this well.

02:03.710 --> 02:12.410
The machine can't actually run C++ machine can only run machine code which is actually the native language

02:12.440 --> 02:14.470
of the machine.

02:14.930 --> 02:22.730
So that's why everything has to be compiled down even further from C++ into something that the machine

02:23.450 --> 02:24.440
can understand.

02:24.440 --> 02:31.130
Remember I said computers are kind of dumb so they don't really know many languages and only really

02:31.130 --> 02:32.510
understand one.

02:32.600 --> 02:43.620
And this is machine language and here's a picture of kind of how the compiler works it'll take all our

02:43.620 --> 02:45.060
C++ files.

02:45.060 --> 02:55.450
In this case not c files and all these other assembly files and put them into these object files these

02:55.830 --> 02:57.810
relocatable object files

03:01.060 --> 03:07.340
and those object files will be input into the linker.

03:07.360 --> 03:14.610
We're not going to go over too much of the linker in this course but the linker takes all the object

03:14.620 --> 03:19.230
files as input and really kind of bundles everything together.

03:20.120 --> 03:26.900
Into our executable program it will take more than just our object files that take other things that

03:27.620 --> 03:28.660
we're not going to go over.

03:28.680 --> 03:31.500
But the idea is it will it.

03:31.560 --> 03:37.740
It does the assembling and creates the real program.

03:37.780 --> 03:42.130
Here's another diagram that sort of shows how this works.

03:43.140 --> 03:50.550
So there's one other line in our program that we still don't understand which is the using namespace

03:50.620 --> 03:51.980
SDD.

03:52.290 --> 03:58.800
And this has kind of nothing to do with the compiler or linker but I thought I'd throw this in here

03:58.800 --> 04:03.510
just to just for the sake of completeness really.

04:03.540 --> 04:12.430
So this namespace SDD is a way of organizing code.

04:12.510 --> 04:19.470
In fact just the namespace part of it and we use it because all of the identifiers which have all the

04:19.470 --> 04:31.720
names of things in our IO stream library like scene and C out they all exist in the standard namespace

04:31.740 --> 04:34.710
which is the standard library names.

04:34.710 --> 04:43.380
So if we didn't write the using namespace SDD we'd actually have to write SDD colon colon C out in the

04:43.760 --> 04:56.380
open colon C in so that Koehne colon is really says hey this object C Ouch belongs to this standard

04:56.380 --> 05:04.080
namespace so hopefully that clears up a little bit of those two lines.

05:04.090 --> 05:11.490
I want to sort of demystify them a little bit so that we can continue on and start learning about constants

05:11.500 --> 05:12.250
next time.
