PDF download Download Article PDF download Download Article

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, it runs interchangeably on x32 and x64.
Part 1
Part 1 of 19:

Configuring Visual Studio

PDF download Download Article
  1. 1
    Highlight what you expect to do. Highlight a 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

PDF download Download Article
  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 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 the 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" (see image above).
    • Open folder C:\ GL.
    • In the new File Explorer click folder "SFML-2.5.1" > click it again and drag into folder C:\GL.
    • Copy SFMLx32 and once copying and pasting of the folder is complete, click folder > right click > click "Rename" (in Windows 11 it is an icon) > paste > hit Enter .
    • Now in folder GL you have folder "SFMLx32".
    • Close downloading new File Explorer window > close SFML window.
  3. Advertisement
Part 3
Part 3 of 19:

Creating Project targeting x32 Platform

PDF download Download Article
  1. 1
    Create empty project.
    • If it's the first time you open Visual Studio . Click Create a new project .
      • In Create a new project wizard, find Empty Project Start from scratch with C++ for Windows. Provides no starting files. (see image above. If it's not visible, enter its name in the search bar above the list and press Enter ) > click it > click Next .
      • In Configure your new project wizard for "Project name" type (or copy and paste) SFMLx32-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 it's not the first time . In main menu click File > New > Project… > the rest as above.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
    • In "Add New Item" wizard instead of "FileName", type Main > hit Enter . The source file Main.cpp will open in the main text editor but leave the file blank for now.
  2. Advertisement
Part 4
Part 4 of 19:

Setting up SFMLx32 in the Project

PDF download Download Article
  1. 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 > click "Edit the System Environment Variables". "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables... . "Environment Variables" wizard is thrown.
    • In the "System Variables" section (the second one) double click the "Path" (or "PATH") Variable. "Edit environment 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

PDF download Download Article
  1. 1
    Test your project. Right click on the 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 or in Visual Studio's main menu click the green triangle with phrase "Local Windows Debugger". Two windows should appear: one black (the console) and one small with a green circle on a 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
        • Check whether folder SFMLx32 exists in C:\GL. If it exists,
        • go to previous Part, step 1, sub step 2. Additional Include Directories and follow instructions.
      • 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. .
    • Thrown wizard about System or file .dll, go to previous Part step 2 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 SFMLx32-0 Template

PDF download Download Article
  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 click File > New > Project... .
    • In Create a new project wizard, in the list of templates, select SFMLx32-0 (if it's not visible, enter its name in the search bar above the list and press Enter ) > 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 or in Visual Studio's main menu click the green triangle with phrase "Local Windows Debugger". 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

PDF download Download Article
  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 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 the 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" (see image above).
    • Open folder C:\ GL.
    • In the new File Explorer, click folder "SFML-2.5.1" > click it again and drag into folder C:\GL.
    • Copy SFMLx64 and once copying and pasting of the folder is complete, click folder > right click > click "Rename" (in Windows 11 it is an icon) > paste > hit Enter .
    • Now in folder GL you have folder "SFMLx64".
    • Close downloading window > close SFML window.
  3. Advertisement
Part 8
Part 8 of 19:

Creating Project for platform x64

PDF download Download Article
  1. 1
    Create empty project.
    • If it's the first time you open Visual Studio . Open it > click Create a new project .
      • In Create a new project wizard, find Empty Project Start from scratch with C++ for Windows. Provides no starting files. (see image above. If it's not visible, enter its name in the search bar above the list and press Enter ) > 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 it's not the first time . In main menu click File > New > Project… > the rest as above.
    • 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.
  2. Advertisement
Part 9
Part 9 of 19:

Installing SFMLx64 in the Project

PDF download Download Article
  1. 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 > click "Edit the System Environment Variables". "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables... . "Environment Variables" wizard is thrown.
    • In the "System Variables" section (the second one) double click the "Path" (or "PATH") Variable. "Edit environment 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

PDF download Download Article
  1. 1
    Test your project. Right click on the 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 or in Visual Studio's main menu click the green triangle with phrase "Local Windows Debugger". Two windows should appear: one black (the console) and one small with a green circle on a 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
        • Check whether folder SFMLx64 exists in C:\GL. If it exists,
        • go to previous Part, step 1, Additional Include Directories and follow instructions.
      • file with extension .lib go to previous Part, step 1, Additional Library Directories , and follow instructions. Also to Additional Dependencies .
    • Thrown wizard about System or file .dll, go to previous Part step 2 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

PDF download Download Article
  1. 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 click File > New > Project... .
    • In Create a new project wizard select SFMLx64-0 (if it's not visible, enter its name in the search bar above the list and press Enter ) > 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 or in Visual Studio's main menu click the green triangle with phrase "Local Windows Debugger". 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

PDF download Download Article
  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
  4. 4
    Copy and unzip the zip folder.
    • Open folder C:\GL
    • In the new File Explorer, click unzip folder cmake-3.29.2-windows-x86_64 > click it again and drag into C:\GL.
    • Once the folder has completed copying and pasting, copy CMake > click folder > right click > click "Rename" (in Windows 11 it is an icon) > Paste > hit Enter .
    • Close the new "File Explorer" window > close the "CMake" window.
    • Double click folder "CMake" > double click folder bin > inside you should see CMake's logo next to file name cmake-gui > double click this file. Now on your screen you have CMake GUI > go back to GL folder.
    • 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

PDF download Download Article
  1. 1
    Download source code. Right-click on the 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.
    • Open folder C:\ GL.
    • In the new File Explorer, click folder "SFML-2.5.1" (or the most recent version) and drag into C:\GL.
    • Copy SFMLsrc and once copying and pasting of the folder is complete, click folder > right click > click "Rename" (in Windows 11 it is an icon) > paste > hit Enter .
    • Now in folder GL you have folder "SFMLsrc".
    • Close downloading window > close SFML window.
  3. Advertisement
Part 14
Part 14 of 19:

Building Source SFML

PDF download Download Article
  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

PDF download Download Article
  1. 1
    Create empty project.
    • If it's the first time you open Visual Studio . Open it > click Create a new project .
      • In Create a new project wizard, find Empty Project Start from scratch with C++ for Windows. Provides no starting files. (see image above. If it's not visible, enter its name in the search bar above the list and press Enter ) > 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 it's not the first time . In main menu click File > New > Project… > the rest as above.
    • 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.
  2. Advertisement
Part 16
Part 16 of 19:

Setting up compiled SFML Source

PDF download Download Article
  1. 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 > click "Edit the System Environment Variables". "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables... . "Environment Variables" wizard is thrown.
    • In the "System Variables" section (the second one) double click the "Path" (or "PATH") Variable. "Edit environment 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

PDF download Download Article
  1. 1
    Test your project. Right click on the 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 or in Visual Studio's main menu click the green triangle with phrase "Local Windows Debugger". Two windows should appear: one black (the console) and one small with a green circle on a 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
        • Check whether folder SFMLsrc exists in C:\GL. If it exists,
        • go to previous Part step 1, sub step 2. Additional Include Directories .
      • file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories . Also to sub step 4. Additional Dependencies .
    • 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 "SFMLsrc-0" Template

PDF download Download Article
  1. 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. Go to Visual Studio main menu and click File > New > Project... .
    • In Create a new project wizard select SFMLsrc-0 (if it's not visible, enter its name in the search bar above the list and press Enter ) > 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 or in Visual Studio's main menu click the green triangle with phrase "Local Windows Debugger". 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

PDF download Download Article
  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

Search
Add New Question
  • Question
    There is no "Export template" option, what should I do? I am using the community version.
    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.
Ask a Question
      Advertisement

      Video

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!

      Expert Interview

      Thanks for reading our article! If you’d like to learn more about visual studio, check out our in-depth interview with Tyrone Showers .

      About This Article

      Thanks to all authors for creating a page that has been read 55,404 times.

      Is this article up to date?

      Advertisement