SFML is a valuable tool for developing games, and it can be added to Visual Studio if you check the Desktop development with C++ workload, "Language pack", and "English" boxes during VS installation. This wikiHow article will teach you how to set up SFML on Visual Studio 2022. It is addressing the beginner.

Things You Should Know

  • Download the 32-bit or 64-bit or source library based on the programs you want to compile, not which OS you have.
  • Visual Studio 2022 is by default x64. However runs interchangeably on x32 and x64.
Part 1
Part 1 of 19:

Configuring Visual Studio

  1. 1
    Highlight what you expect to do. Highlight step or sub-step you expect to do and then do it. See as example picture above.
  2. 2
    Download Visual Studio 2022. If you have not done so you can download it from https://www.visualstudio.com/downloads.
  3. Advertisement
Part 2
Part 2 of 19:

Downloading  SFML x32

  1. 1
    Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
    • If folders GL and GLP exist it's okay.
    • If they do not, right click in empty area > select New > Folder > type GL > hit Enter. By same way create folder GLP.
  2. 2
    Download the latest stable version of SFML. Right click on following address and select Open Link in New Window https://www.sfml-dev.org/download/sfml/2.5.1/. Click the first button, today Download 16.3 MB, next to "Visual C++ 15 (2017) - 32-bit".
    • In downloads directory, click folder SFML-2.5.1 (or latest version) > right click > Copy.
    • Navigate to C: > GL > right click > select Paste.
    • (Alternatively click folder SFML-2.5.1 (or latest version) and drag into File Explorer > C: > GL).
    • After copying and unzipping have been finished, click on name SFML-2.5.1 (or latest version) and rename to SFMLx32
  3. Advertisement
Part 3
Part 3 of 19:

Creating Project targeting x32 Platform

  1. 1
    Create empty project.
    • If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
      • In Configure your new project wizard, in "Project name" text field type: SFMLx32-0
      • In "Location" text field delete everything, copy C:\GLP\ and paste.
      • Check "Place solution and project in the same directory" > click Create.
      • Wait till Visual Studio instance appears.
    • If Visual Studio is open. Click File > New > Project… > Empty Project > Next. The rest as above.
  2. 2
    Add your Source file to the project.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
    • Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
  3. Advertisement
Part 4
Part 4 of 19:

Setting up SFMLx32 in the Project

  1. 1
    Configure "Property Pages". Go to "Solution Explorer" > right click on the name of your project SFMLx32-0 > select "Properties" (the last one). In "SFMLx32-0 Property Pages" wizard,
  2. 2
    Add dll file path (address) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit Enter. "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
    • Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
    • Copy C:\GL\SFMLx32\bin > click New > Paste.
    • Click OK in all 3 wizards.
    • Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
    • Restart your PC > open Visual Studio. In "Open recent" list, click "SFMLx32-0.sln", the first one. Now your project is open ready for test.
  3. Advertisement
Part 5
Part 5 of 19:

Testing project SFMLx32-0 and Correcting errors

  1. 1
    Test your project. Right click on following address and select Open Link in New Window https://www.sfml-dev.org/tutorials/2.5/start-vc.php scroll down the page and copy the code.
    • Go to Visual Studio and paste in Main.cpp code area > in main menu select x86 > hit Ctrl+F5. Two windows should appear: one black (the console) and one small with green circle in black background. Good job.
  2. 2
    Correct errors if any. Files are missing. Copy C:\GLP\SFMLx32-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 3, step 2, and add it now.
    • In "Error List" if you see error about
      • file with extension .h go to previous Part, step 1, sub step 2. Additional Include Directories and follow instructions. Also check whether folder SFMLx32 exists in C:\GL.
      • file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories, and follow instructions. Also to sub step 4. Additional Dependencies..
      • "entry point must be defined" go to previous Part, step 1, sub step 5. System, and follow instructions.
    • Thrown wizard about System or file .dll, go to previous Part, steps 2 and 3, and follow instructions.
    • For other errors, if you can not correct them, close Visual Studio > delete project folder SFMLx32-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 3. Good job.
  3. Advertisement
Part 6
Part 6 of 19:

 Creating project with Template targeting x86 Platform

  1. 1
    Create Template. Go to Visual Studio main menu. While "SFMLx32-0" is open, click Project > Export Template....
    • In Choose Template Type menu, leave Project template checked. Click Next....
    • In  Select Template Options, Template name: should be SFMLx32-0 > click Finish. The template is created. Close thrown window with template's path.
  2. 2
    Create Project. In Visual Studio main menu select x86 > click File > New > Project....
    • In Create a new project wizard, in the list of templates, select SFMLx32-0 (if necessary scroll down the list) > click  Next.
    • In Configure your new project wizard, Project name: should be SFMLx32-01 .
    • Location should be C:\GLP\. If it's not, delete path, copy C:\GLP and paste.
    • Be sure Place solution and project in the same directory is checked. Click Create.
    • In Visual Studio's GUI main menu, select x86 > hit Ctrl+F5. Good job.
    • TIP. When you create project with this template remember in Visual Studio main menu select x86.
  3. Advertisement
Part 7
Part 7 of 19:

Downloading SFMLx64

  1. 1
    Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
    • If folders GL and GLP exist it's okay.
    • If they do not, right click in empty area > select New > Folder > type GL > hit Enter. By same way create folder GLP.
  2. 2
    Download the latest stable version of SFML 64 bit. Right click on following address and select Open Link in New Window https://www.sfml-dev.org/download/sfml/2.5.1/. Click the first button in the right list, today Download 18.0 MB next to "Visual C++ 15 (2017) - 64-bit".
    • In downloading window, click the folder SFML-2.5.1 (or the latest) > right click > Copy.
    • Navigate to C: > GL > right click > select Paste.
    • After copying and unzipping have been finished click on name SFML-2.5.1 and rename to SFMLx64
  3. Advertisement
Part 8
Part 8 of 19:

Creating Project for patform x64

  1. 1
    Create empty project.
    • If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
      • In Configure your new project wizard for "Project name" type (or copy and paste) SFMLx64-0
      • Copy C:\GLP and paste in "Location" text field.
      • Check "Place solution and project in the same directory".
      • Click Create.
      • Wait till Visual Studio instance appears.
    • If Visual Studio is open. In main menu click File > New > Project… > the rest as above.
  2. 2
    Add your Source file to the project.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
    • Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
  3. Advertisement
Part 9
Part 9 of 19:

Installing SFMLx64 in the Project

  1. 1
    Configure "Property Pages". Go to "Solution Explorer" > right click on the name of your project SFMLx64-0 > select "Properties" (the last one). In "SFMLx64-0 Property Pages" wizard,
  2. 2
    Add dll file path (address) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit Enter. "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
    • Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
    • Copy C:\GL\SFMLx64\bin > click New > Paste.
    • Click OK in all 3 wizards.
    • Close Visual Studio > in thrown wizard "Save changes to the following items?" click Save.
    • Restart your PC > open Visual Studio. In "Open recent" list, click "SFMLx64-0.sln", the first one. Now your project is open ready for test.
  3. Advertisement
Part 10
Part 10 of 19:

Testing Project SFMLx64-0 and Correcting errors

  1. 1
    Test your project. Right click on following address and select Open Link in New Window https://www.sfml-dev.org/tutorials/2.5/start-vc.php scroll down the page and copy the code.
    • Go to Visual Studio and paste in Main.cpp code area > in main menu select x64 > hit Ctrl+F5. Two windows should appear: one black (the console) and one small with green circle in black background. Good job.
  2. 2
    Correct any errors. Files are missing. Copy C:\GLP\SFMLx64-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 7, step 4, and add it now.
    • In "Error List" if you see error about
      • file with extension .h go to previous Part, step 1, Additional Include Directories and follow instructions. Also check whether folder SFMLx64 exists in C:\GL.
      • file with extension .lib go to previous Part, step 1, Additional Library Directories, and follow instructions. Also to Additional Dependencies.
      • "entry point must be defined" go to previous Part step 1, substep System and follow instructions.
    • Thrown wizard about System or file .dll, go to previous Part steps 2 and 3, and follow instructions.
      • For other errors, if you can not correct them, close Visual Studio > delete project folder SFMLx64 which lives in C:\GLP > open Visual Studio > repeat set up from Part 7 Installing SFMLx64 in the Project. Good job.
  3. 3
    Tip: Even if in Property Pages main settings it is Platform: x64, click Configuration manager... and in Active solution platform: select x64.
  4. Advertisement
Part 11
Part 11 of 19:

Creating Project targeting x64 Platform, with Template

  1. 1
    Create Template. Go to Visual Studio main menu. While "SFMLx64-0" is open, click Project > Export Template....
    • In Choose Template Type menu, leave Project template checked. Click Next....
    • In Select Template Options, Template name: should be SFMLx64-0 > click Finish. The template is created. Close thrown window with template's path.
  2. 2
    Create Project. In Visual Studio main menu select x64 > click File > New > Project....
    • In Create a new project wizard select SFMLx64-0 (if necessary scroll down the list of templates) > click Next.
    • In Configure your new project wizard, Project name should be SFMLx64-01.
    • Location should be C:\GLP\. If it's not, delete path, copy C:\GLP and paste.
    • Be sure Place solution and project in the same directory is checked. Click Create, and wait till project be created.
    • In Visual Studio GUI's main menu, select x64. Hit Ctrl+F5. Good job.
  3. 3
    TIP: In every project you create with this template, remember, in Visual Studio GUI main menu, select x64 (next to Debug).
  4. Advertisement
Part 12
Part 12 of 19:

Installing CMake

  1. 1
    Compiling a library from the source code guarantees that the resulting library is perfectly tailored for your CPU/OS, a luxury pre-compiled binaries don't always provide. It is also important that binaries you get target x64 platform.
  2. 2
    Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
    • If folders GL and GLP exist it's okay.
    • If they do not, right click in empty area > select New > Folder > type GL > hit Enter. By same way create folder GLP.
  3. 3
    Download CMake. Right-click on following address and select Open Link in New Window https://cmake.org/download/. Scroll down the page and find "Latest Release (3.25.1)", (or latest). In second "Platform" list, find (see image above) "Windows x64 ZIP" and click the beside entry cmake-3.26.0-windows-x86_64.zip (or latest) > in opening wizard select Save file.
  4. 4
    Copy and unzip the zip folder.
    • If the downloaded folder doesn't contain line with stripes (unzipped folder) click it > right click > Copy.
    • If downloaded folder's icon contains vertical line with stripes (zipped folder), double click it for get unzipped folder, (or alternatively, click folder > right click > in drop-down menu select Extract all).
      • When unzipping (extracting files) is finished, click unzip folder cmake-3.26.0-windows-x86_64.zip (or latest) > right click > Copy.
    • Go to drive (directory) C: > GL > right click > Paste.
    • (Alternatively click folder "cmake-3.26.0-windows-x86_64" and drag into folder "GL").
    • When copying is finished click folder "cmake-3.26.0-windows-x86_64" > right click > select "Rename" > type CMake > hit Enter > double click it > double click folder bin > inside you should see CMake's logo next to file name cmake-gui > double click this file. If wizard "Windows protect your PC" appears, click More information > Run anyway. Now on your screen you have CMake GUI.
    • Each time you need CMake, navigate to C:\ > GL > double click folder CMake > double click "bin" > double click file cmake-gui (the one with CMake's logo).
  5. Advertisement
Part 13
Part 13 of 19:

Downloading Source Code

  1. 1
    Download source code. Right-click on following address and select Open Link in New Window https://www.sfml-dev.org/download/sfml/2.5.1/. Scroll down to the bottom (see above image), in All select Source code and click Download 22.2 MB.
  2. 2
    Copy and unzip folder.
    • In downloading window click zip folder SFML-2.5.1-sources.zip (or latest version) > right click > select Copy.
    • Navigate to C:\ > GL > right click > select Paste.
    • Now in directory C:\GL, you have unzip folder SFML-2.5.1. Click twice on its name > delete name > type SFMLsrc > hit Enter.
  3. Advertisement
Part 14
Part 14 of 19:

Building Source SFML

  1. 1
    Build SFML by CMake and Visual Studio. Go to CMake GUI. See above image.
    • In text field next to Where is the source code (first text field), type (or copy and paste, attention: do not copy any space)C:/GL/SFMLsrc
    • In text field next to Where to build the binaries (second text field), type (or copy and paste, attention: do not copy any space)C:/GL/SFMLsrc/build
    • Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > in wizard "Specify the generator for this project" click Finish.
    • When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
      • If, instead, wizard "Error" is thrown, click OK > click "File" > click "Delete Cache" > in thrown wizard "Delete Cache", click Yes.
  2. 2
    Build your solution.
    • Copy C:\GL\SFMLsrc\build and paste in File Explorer Address bar > hit Enter > double click "SFML.sln", or "SFML", or "ALL_BUILD.vcxproj". An instance of Visual Studio appears. In the main menu, click "Build" > click "Build Solution".
    • Wait till you read the last line in "Output" window: ========== Build: 8 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========
      • TIP: Number of "succeeded" changes in SFML versions. Today(09-Nov-2022) is 8.
    • Close this instance of Visual Studio. Close CMake GUI.
  3. Advertisement
Part 15
Part 15 of 19:

Creating Project SFMLsrc-0

  1. 1
    Create empty project.
    • If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
      • In Configure your new project wizard for "Project name" type (or copy and paste) SFMLsrc-0
      • Copy C:\GLP and paste in "Location" text field.
      • Check "Place solution and project in the same directory".
      • Click Create.
      • Wait till Visual Studio instance appears.
    • If Visual Studio is open. In main menu click File > New > Project… > the rest as above.
  2. 2
    Add your Source file to the project.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
    • Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
  3. Advertisement
Part 16
Part 16 of 19:

Setting up compiled SFML Source

  1. 1
    Configure project's Properties. In Solution Explorer wizard, right click Project's name that is SFMLsrc-0 > select Properties (the last one). In "SFMLsrc-0 Property Pages" wizard, .
  2. 2
    Add dll file path (address) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit Enter. "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
    • Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
    • Copy C:\GL\SFMLsrc\build\lib\Debug > click New > Paste.
    • Click OK in all 3 wizards.
    • Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
    • Restart your PC > open Visual Studio. In "Open recent" list, click SFMLsrc-0.sln, the first one. Now your project is open ready for test.
  3. Advertisement
Part 17
Part 17 of 19:

Testing project SFMLsrc-0 and Correcting errors

  1. 1
    Test your project. Right click on following address and select Open Link in New Window https://www.sfml-dev.org/tutorials/2.5/start-vc.php scroll down the page and copy the code.
    • Go to Visual Studio and paste in Main.cpp code area > in main menu select x64 > hit Ctrl+F5. Two windows should appear: one black (the console) and one small with green circle in black background.
  2. 2
    Correct any errors. Files are missing. Copy C:\GLP\SFMLsrc-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 12, step 2, and add it now.
    • In "Error List" if you see error about
      • file with extension .h go to previous Part step 1, sub step 2. Additional Include Directories. Also check whether folder SFMLsrc exists in C:\GL.
      • file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories. Also to sub step 4. Additional Dependencies.
      • "entry point must be defined" go to previous Part, step 1, sub step 5. System.
    • Thrown wizard about System or file .dll, go to previous Part, steps 2 and 3.
    • For other errors, if you can not correct them, close Visual Studio > delete project folder SFMLsrc-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 12. Good job.
  3. Advertisement
Part 18
Part 18 of 19:

Creating Project with Template SFMLsrc-0

  1. 1
    Create Template. Go to Visual Studio main menu. While "SFMLsrc-0" is open, click Project > Export Template....
    • In Choose Template Type menu, leave Project template checked. Click Next....
    • In Select Template Options, Template name: should be SFMLsrc-0 > click Finish. The template is created. Delete thrown window with template's path.
  2. 2
    Create Project. Click File > New > Project....
    • In Create a new project wizard select SFMLsrc-0 (if necessary scroll down the list of templates) > click Next.
    • In Configure your new project wizard, Project name should be SFMLsrc-01.
    • Location should be C:\GLP\. If it's not, delete path, copy C:\GLP and paste.
    • Be sure Place solution and project in the same directory is checked. Click Create, and wait till project be created.
    • In Visual Studio main menu select x64 > hit Ctrl+F5. Good job.
  3. 3
    TIP: Remember, in every project you create with this template, select x64 (next to Debug) in Visual Studio's GUI.
  4. Advertisement
Part 19
Part 19 of 19:

Choosing Set Up

  1. 1
    In this tutorial you learn 3 was to set up SFML in Project with Visual Studio.
    • Set up binaries x86 (32 bits). It's the easiest. You should start learning set up from here.
    • Set up binaries x64 (64 bits). It targets x64 platform. Choose it only when you have specific reason for doing so.
    • Compile SFML source, and set up in project. Targets x64 too.The most difficult. The best though.

Community Q&A

  • Question
    There is no "Export template" option, what should I do? I am using the community version.
    Community Answer
    Community Answer
    If the "Export template" options is unavailable, then it is likely that you failed to keep open "Project-0" when trying to export the template. It is the mother or patron project for creating the template with it. If there is no project open, you can't create a template, so there is no "Export Template" option.
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 12 people, some anonymous, worked to edit and improve it over time. This article has been viewed 38,031 times.
How helpful is this?
Co-authors: 12
Updated: March 21, 2023
Views: 38,031
Advertisement