Setting up SFML 2.4.1 in Visual Studio 2015

Vishal Rashmika published on
3 min, 589 words

Categories: SFML

Downloading SFML 2.4.1

First Download the SFML-2.4.1 32-bit file for Visual Studio 2015 Download Link

After downloading extract the zip file. Inside it you will be able to find a folder named SFML-2.4.1 move that folder to one of your prefered locations, in my case I will move it the my C:\MinGW directory.

Setting up visual studio 2015

Create a new visual c++ win32 console application.

In the prompt click next.

Tick empty project and click finish to create an empty project.

Navigate to the solution explorer and right click on the project and select properties.

In the properties panel make sure you have selected Active(Win32) as your platform and All Configurations for you configuration.

Navigate to the VC++ Directories > Include Libraries > Edit.

In the Include Directories window click add new line and press ... to select the directory.

Navigate to the directory that you placed the SFML directory previously and select the include folder inside the SFML-2.4.1 directory . In my case the directory was ``C:\MinGW\SFML-2.4.1\include`.

Next, navigate to the Library Directories Section in VC++ Directories category and press edit.

In the Library Directories window click add new line and press ... to select the directory.

Navigate to the directory that you placed the SFML directory previously and select the lib folder inside the SFML-2.4.1 directory . In my case the directory was ``C:\MinGW\SFML-2.4.1\lib`.

Next navigate to the Input section under the Linker Category. and edit the Additional Dependencies.

In the 'Additional Dependencies' window add the following lines and press 'Ok'.

sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib

press 'apply'

Next select release from the configuration drop down.

In the Input section in Linker Category edit the Additional Dependencies.

The 3 lines that we previously entered (sfml-graphics-d.lib, sfml-window-d.lib, sfml-system-d.lib ) will be present in this window remove the -d part from the 3 lines so that it becomes,

sfml-graphics.lib
sfml-window.lib
sfml-system.lib

Press Ok'.

Press 'Apply', 'Ok' and save the changes.

Navigate to the folder that you saved the SFML-2.4.1 and go inside the /bin/ directory and copy the 11 files in that directory.

Go the directory that you created you visual c++ win32 console application and navigate inside the project directory and paste the 11 files in that directory.

Setting up SFML is done now let's test it.

Testing

Go to the solution explorer. Under the source files category add a new .cpp file named anything I will name this as main.cpp.

Paste the following code in the .cpp file

#include <SFML/Graphics.hpp>

int main()
{
	sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
	sf::CircleShape shape(100.f);
	shape.setFillColor(sf::Color::Green);

	while (window.isOpen())
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
				window.close();
		}

		window.clear();
		window.draw(shape);
		window.display();
	}

	return 0;
}

Finally run the application

You will see a new screen with the following output.