Link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window
Windows specific, and your code would therefore not compile on Linux or macOS, SFML provides a way to keep a standard "main" entry point in this case: If you chose to create a "Windows application" project, the entry point of your code has to be set to "WinMain" instead of "main". Sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!") Put the following code inside the main.cpp file: Your project is ready, let's write some code now to make sure that it works. There are many good articles/blogs/posts about them. If you don't know the differences between dynamic (also called shared) and static libraries, and don't know which one to use, you can search for more information on the internet. If somethingĭoesn't work for you the first time around, you can simply keep trying always bearing in mind what has been said above. If you are slightly confused, don't worry, it is perfectly normal for beginners to be overwhelmed by all this information regarding static linking.
If anything along the dependency chain is missing, you will get linker errors.
If you static link to an SFML library, make sure to link to the dependencies of the library in question, as well as the dependencies of the dependenciesĪnd so on. sfml-graphics-s.lib depends both on sfml-window-s.lib and sfml-system-s.lib. You might have noticed from the table that SFML modules can also depend on one another, e.g. Here are the dependencies of each module, append the -d as described above if you want to link the SFML debug libraries: Might already be listed under "Inherited values", but adding them again yourself shouldn't cause any problems. Sfml-window-s.lib or sfml-window-s-d.lib for example, you will also have to link opengl32.lib, winmm.lib and gdi32.lib. Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well. In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project. Libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release. If you want to get rid of these DLLs and have SFML directly integrated into your executable, you must link to the static version. The settings shown here will result in your application being linked to the dynamic version of SFML, the one that needs the DLL files. It is important to link to the libraries that match the configuration: "sfml-xxx-d.lib" for Debug, and "sfml-xxx.lib" for Release. Need, for example "sfml-graphics.lib", "sfml-window.lib" and "sfml-system.lib". Libraries must be added in the project's properties, in Linker » Input » Additional Dependencies. Network and audio), and there's one library for each of them. SFML is made of 5 modules (system, window, graphics, The next step is to link your application to the SFML libraries (.lib files) that your code will need.
These paths are the same in both Debug and Release configuration, so you can set them globally for your project ("All configurations"). The path to the SFML libraries ( /lib) to Linker » General » Additional Library Directories.The path to the SFML headers ( /include) to C/C++ » General » Additional Include Directories.Now we need to tell the compiler where to find the SFML headers (.hpp files), and the linker where to find the SFML libraries (.lib files). (otherwise Visual Studio doesn't know which language you're going to use for this project).
The dialog window offers a few other options to customize the project: select "Console application" or "WindowsĪpplication" only if you know how to use pre-compiled headers.įor the purpose of this tutorial, you should create a main.cpp file and add it to the project, so that we have access to the C++ settings It is recommended to select "Empty Project". The first thing to do is choose what kind of project to create. To keep libraries in their own separate location, especially if you intend to use several versions of the same library, or several compilers. Copying headers and libraries to your installation of Visual Studio is not recommended, it's better
You can then unpack the SFML archive wherever you like. If there's no SFML package compiled for your version of Visual C++, you will have to Won't be compatible with VC++ 12 (Visual Studio 2013) for example. Indeed, a library compiled with VC++ 10 (Visual Studio 2010)
You must download the package that matches your version of Visual C++. It will explain howįirst, you must download the SFML SDK from the download page. This tutorial is the first one you should read if you're using SFML with the Visual Studio IDE (Visual C++ compiler).