SFML Setup in Visual Studio Code | Create C/C++ Applications using SFML + VSCode + MinGW-w64

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in a previous video that you can find in the description i explained how to set up visual studio code for c development in this video i will show you how to create a simple c plus application using sfml library so first let's download the sfml library then let's go to this first link and let's click on download then let's click on this button sfml 2.5.1 in this page we have several versions of the binaries but we need to download the binaries that were obtained using the same version of the compiler in my case i am using mingw for 64-bit systems so i have just to download this binaries so let's click on download then we need to download this zip file in my case i have already downloaded it so i will cancel this download so this is the zip file of sfml i need just to extract it now i will move this folder to my documents now let's create a new c plus project using visual studio code so i will call it first sfml project now let's create a new c file and let's complete this file using an example that we can find on the website of sfml so let's click on learn then tutorials and here let's click on sfml and linux now let's scroll down and let's copy this example now let's save this file and here we have this error because intellisense did not find this include so to fix this i have just to click on quick fix then edit include path setting so this folder has been created and it contains this file i can open this file like this or also i can open this file using this link so this is the file that we obtained now let's close this page and here we need to provide the path of the include folder of sfml so let's go to the folder that contains the sfml library it is on documents into a folder called libraries and this is the sfml folder so let's open the include folder and let's copy this path now let's add it just here so let's add a comma then double quotes and let's paste the path of course i need to add a second slash to fix the errors now let's save this file and let's close it and here we can see that the error disappeared now to compile this source file i have just to go back to the documentation website and to copy this command and let's open a new terminal and let's paste the command of course we need to correct this path so i need just to copy this path and let's paste it just here in my case i don't have spaces in this path so i don't need to add the double quotes but if there are spaces in this case i need to add double quotes so let's add the double quotes and let's hit enter now the file has been compiled correctly and this is the output now let's go back to the documentation website and let's copy this command let's paste it here so this is the name of the application that will be created i want to modify it i will call my application main also i need to modify this path so let's go to the folder that contains sfml let's open the leap folder and let's copy this path also it is possible to add this path between codes in case we have spaces and let's hit enter and here we obtain this executable file so let's run it and here i have this error this is because i did not add the dll files to the folder that contains my executable file so let's fix this so this is the folder that contains the dlls i have just to copy all of these dlls and to put them into the folder that contains my executable file now let's execute the application again and we obtain this window now i will show you how to build this application statically so we don't need these dll files so let's close this window and let's go to the navigator now let's click on learn then tutorials and then sfml and visual studio in this page we need to scroll down and here we can see that if we want to build the application statically we need to use the static sfml libraries which have the mines s suffix also we need to define sfml static and finally we need to add these dependencies so let's do this so to compile the source code i need to use this command and i need to add mines d sfml static now let's hit enter and to link the object file i need to use this previous command but i need to add mines suffix also i need to add the other dependencies now let's hit enter and the application has been created now let's go to the folder that contains our application and let's remove all of these dll files now let's run this application so we obtain this window and we don't have any error it is possible that when we start this application a terminal will be opened to hide the terminal it is necessary to add a new leap so let's close this window and let's go to the documentation website so let's scroll down and here to hide the terminal we need just to add this now let's hit enter and the application has been built again now to build this application easily i will create a simple make file and then i will create the default rule that i will call all this rule depends on other rules called compile and link now let's define the compile rule this rule will just compile the source code now let's create the link rule and this rule will just link the object file now let's create the clean rule so this rule will just delete the executable file and the object file now let's save this make file let's call make clean and we can see that the executable file and the object file have been deleted now let's call make and here we obtain this executable file so let's go to the folder that contains this file and let's run this application so this is the obtained window now i will show you how to use the examples that are available with the sfml library so let's close this window and let's go to the folder that contains sfml so here we have several examples so let's open this example let's open the source code let's copy this source code and let's paste it just here now let's save this file and let's run make now let's open the folder that contains this executable file and let's run this application and this is the obtained window finally thank you very much for watching and please subscribe to the channel
Info
Channel: BoostMyTool
Views: 57,469
Rating: undefined out of 5
Keywords:
Id: rZE700aaT5I
Channel Id: undefined
Length: 10min 49sec (649 seconds)
Published: Sat Nov 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.