WEBVTT

00:00.150 --> 00:00.660
Hello again!

00:00.960 --> 00:05.130
In this video, we are going to look at how to configure a compiler to work with SFML.

00:05.790 --> 00:10.410
I am going to assume that you have successfully downloaded the binaries for your system and your compiler,

00:10.830 --> 00:16.200
and you know where to find them. To get the compiler to use SFML,

00:16.210 --> 00:18.150
we need to give it some information.

00:18.660 --> 00:24.210
We need to tell it where to find the headers for SFML, where to find the library files for

00:24.390 --> 00:24.900
SFML.

00:25.320 --> 00:29.640
And also, which of these library files we actually want to have built into the program.

00:30.870 --> 00:36.420
If you are using a command line on a Unix system, you'd probably have something like this. Minus capital 'I',

00:36.960 --> 00:44.040
then the directory with the headers. Minus capital 'L', then the directory with the libraries, and then, minus 'l and

00:44.040 --> 00:46.590
the library name, for each of the libraries that you want.

00:48.030 --> 00:51.180
So I am actually doing this in MinGW, on Windows.

00:51.690 --> 00:55.080
So there is where I installed my SFML.

00:55.710 --> 00:58.090
The headers are in the include directory underneath

00:58.090 --> 01:01.340
that. The library files are in the "lib" directory.

01:02.220 --> 01:06.870
And then I have these three libraries that I want to build into my program.

01:09.290 --> 01:10.040
And then if I run it...

01:11.240 --> 01:15.470
Now, if this was a Unix system, then the program would be able to work out where the shared objects

01:15.470 --> 01:17.000
are, and load them up when it starts.

01:17.660 --> 01:22.730
As this is Windows, the shared objects have to be in the same directory as the program binary.

01:23.210 --> 01:28.400
So I need to copy them. And they are in the "bin" directory in my installation.

01:31.590 --> 01:31.850
And then - there we are.

01:32.550 --> 01:34.930
So there is my basic window, and it is very basic!

01:34.950 --> 01:37.580
It does not do anything, but it is a start.

01:39.510 --> 01:45.150
If you are using an Integrated Development Environment, then the basic principles are the same,

01:45.150 --> 01:50.640
but the actual details are going to vary. Which dialogue box you have to click on, which field you have to

01:50.640 --> 01:51.060
edit, and

01:51.060 --> 01:57.660
so on. It will depend on the actual editor. But generally there will be something like "Additional Include

01:57.660 --> 02:02.250
Directories", where you put the path for the headers, "Additional Library Directories", where you put the

02:02.250 --> 02:07.170
path to the libraries, and then "Additional Dependencies", where you put the library files.

02:09.050 --> 02:11.530
As an example, I am going to use Visual Studio.

02:11.890 --> 02:13.630
I will go through the code in the next video.

02:13.630 --> 02:18.670
So do not worry, if you do not understand it. I will give you the code as a downloadable resource for this

02:18.670 --> 02:21.130
video, if you want to try it out for yourself.

02:22.240 --> 02:32.110
So we need to go into the project properties. And then, for "C++, General", we need to add the path to

02:32.110 --> 02:35.080
the headers, as an additional include directory.

02:37.660 --> 02:43.750
And then for the "Linker, General", we need to add the path to the library files as an additional library

02:43.750 --> 02:51.700
directory. In the "Input", the "Additional Dependencies", we put the libraries that we want to use.

02:52.160 --> 02:57.460
I have added "sfml-main" here, because you might get a warning about not having "WinMain" defined.

02:57.460 --> 02:59.770
And if you get that, then that is how to get rid of it.

03:02.540 --> 03:04.130
So let's try that out.

03:07.960 --> 03:09.200
Right.

03:09.340 --> 03:13.120
So we get an error: "the machine type conflicts with the target machine type".

03:13.780 --> 03:16.690
So I think that means we are mixing 32 and 64 bits.

03:17.320 --> 03:24.760
So let's change that to 64 bits. Then clean the build. Always clean the built after you change any of the

03:24.940 --> 03:25.270
properties.

03:27.730 --> 03:33.020
And then. Right. That compiles, but it cannot execute, because it cannot find the shared objects, the

03:33.020 --> 03:33.530
DLL's.

03:34.190 --> 03:37.340
So again, we have to copy them.

03:38.450 --> 03:49.030
So we need to go to the "C" drive. Usually. Then "users", then your username, then "source", and then "repos".

03:49.970 --> 03:54.830
And then in the project directory. And we are using x64, and then "debug".

03:56.480 --> 03:56.750
Right.

03:56.750 --> 04:00.530
So that is the actual directory where the program binary is.

04:01.580 --> 04:09.320
Then we have to go to our SFML installation, into the "bin" directory. And then to copy all the DLL's, from

04:09.320 --> 04:13.340
this directory into the program executable directory.

04:15.420 --> 04:17.670
And then let's see if it works.

04:18.610 --> 04:19.010
Oh dear!

04:20.170 --> 04:22.950
Now, the program has been aborted.

04:23.820 --> 04:25.450
And by the way, I do actually know how to do this.

04:25.480 --> 04:27.540
I am just trying to show some of the things that can go wrong.

04:28.920 --> 04:31.620
So going back into the project properties.

04:34.160 --> 04:39.590
These are actually the release versions of the shared libraries, but we are actually running it in a debug build.

04:40.310 --> 04:42.430
So we need to use the debug versions.

04:42.440 --> 04:44.600
So these need to have minus "d" after the name.

04:47.930 --> 04:49.250
"main" minus "d", system

04:49.400 --> 04:51.680
minus "d" and window

04:51.680 --> 04:52.220
minus "d".

04:59.100 --> 05:00.590
And at last, there it is!

05:02.440 --> 05:05.530
So as I said, I will go over this code in the next video.

05:06.070 --> 05:10.870
I will also give you this source code and the instructions for installing on Visual Studio, as a downloadable

05:10.900 --> 05:11.380
resource.

05:13.000 --> 05:15.130
That is it for this video, but I will see you next time.

05:15.670 --> 05:17.500
Until then, keep coding!
