Setting up SFML using the libraries I gave you.

Here are the steps you need to go thru to get the following simple program to work.  BTW this is the usual approach for installing a large number of API’s that you might be interested in out there so pay close attention to the process.

#include <SFML/Graphics.hpp>
int main() {
 sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
 sf::CircleShape shape(100.f);
 while (window.isOpen()) {
  sf::Event event;
  while (window.pollEvent(event)) {
    if (event.type == sf::Event::Closed)
  return 0;
  1. Fire up visual studio 15 or 17 and use the above as your main program
  2. Copy the appropriate library directory that I gave you to the c: drive. I will be using the SFML17 version for the below discussion.
  3. Change the solution platform (at the top of vs) from x86 to x64.  Be sure and do this before you do the following.
  4. Go go project:property pages:VC++ directories:include directories and add C:\SFML17-2.4.2\includeNote that this tells visual where to look for your include files ( ie. #include <SFML/Graphics.hpp>)
  5. Go to project:property pages:VC++ directories:libraries and add C:\SFML17-2.4.2\libNote that this tells visual where to look for your lib files ( ie. sfml-graphics-d.lib; sfml-window-d.lib; sfml-system-d.lib; sfml-audio-d.lib) , these are the debug versions denoted by the -d at the end.
  6. Copy the DLL’s from C:\SFML17-2.4.2\bin to your project directory that has the readme file and .cpp files.  This is just one of the places they can be placed. See here for other options.
  7. Go to project:property pages:Linker:input and add sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-audio-d.lib; to the list.  This tells the linker which libs to actually look for in the C:\SFML17-2.4.2\lib directory that you specified above.
  8. Now compile and run the program. If you don’t get external linking errors etc. and it runs, you are amazing. If not double check everything above and try again.  You should get a small window with a large green dot in the middle.
  9. NOTE: I have no idea why the program did not run in class. When I got to my office I reset the above things and it ran.  Must have miss-typed something.  Try the above and see what happens.

Comments are closed.