Can someone help me set up SFML?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
TheCollector
Posts: 41
Joined: August 1st, 2019, 9:57 pm

Can someone help me set up SFML?

Post by TheCollector » August 10th, 2019, 5:01 pm

Okay, so I followed this tutorial for the old SFML (https://www.youtube.com/watch?v=Z6alClFOGoM) and I'm having some trouble.
When I go to add additional dependencies under Input I don't know what file names to be putting in. There's two files for each one in the SFML/bin folder. For instance, there's sfml-graphics-2 and sfml-graphics-d-2. I've tried both and neither have made a difference with the error I'm receiving below. I've also tried what the guy using the old version of sfml was typing in (sfml-graphics-d) and that doesn't make a difference either.

Apparently I have the SFML-2.5.1 folder in the right spot (and I put copies of the sfml/bin files in the same spot in my project folder) because when I type #include "SFML" the SFML 2.5.1 folder pops up. But when I try to follow the rest of the tutorial by typing #include "SFML-2.5.1/Graphics.hpp" I get an error, cannot open the source file.

Anyone know what I'm doing wrong here?

I'm simply trying to load/display an image to the window.

TheCollector
Posts: 41
Joined: August 1st, 2019, 9:57 pm

Re: Can someone help me set up SFML?

Post by TheCollector » August 10th, 2019, 5:26 pm

I just found a video by the same guy I was watching earlier but for SFML 2.4. Going to try this too and see if anything helps get it going. Just to clarify, in the 'include directories' I updated the text from being the older version used in the video to SFML-2.5.1 and in 'additional library directories' put the same but with /lib after so it would reference the newer version of SFML which is what I have.

TheCollector
Posts: 41
Joined: August 1st, 2019, 9:57 pm

Re: Can someone help me set up SFML?

Post by TheCollector » August 10th, 2019, 5:41 pm

Okay, so it is still for example, sfml-graphics-d. I was looking in the wrong folder, the bin folder instead of the lib folder where they are all named -d. So I have the right names in now, still doesn't work though. In the new video he's typing it, #include <SFML/Graphics.hpp> and when I type in the first parts of that nothing comes up for SFML. SFML only comes up when I use quotations.

albinopapa
Posts: 3790
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Can someone help me set up SFML?

Post by albinopapa » August 11th, 2019, 5:47 am

Here's a bit of an explanation on #include syntax, at least as far as VS goes.

#include <filename.h> - means you have added some Include directory in the properties and you want the compiler to look through them first.

#include "filename.h> - means you have files in the project folder that need to be included and you want the compiler to look there.

So, if you have added SFML\Include to your project properties, then you should be able to use: #include <SFML\\Graphics.hpp>.

If you haven't added that folder to your project properties and instead just copied AND imported the files into visual studio, you must type: #include "SFML\\Graphics.hpp".

As for the .lib files, I'm still having issues with that one myself right now, but there are two ways to import them.

First: Add the SFML\lib folder to the directories page
Method 1:
Use the project properties page under Linker \ Input \ Additional Dependancies and add the .lib files to your project
Make sure you have the Configuration set for Release for the release versions and Debug for the debug versions
Release versions: sfml-system.lib, sfml-window.lib, sfml-graphics.lib
Debug versions: sfml-system-d.lib, sfml-window-d.lib, sfml-graphics-d.lib

Method 2:
Add some lines of code, #pragma comment, somewhere and the linker will use them to load the lib files.

Code: Select all

#if defined(NDEBUG) // Release build
#pragma comment( lib, "sfml-system.lib" )
#pragma comment( lib, "sfml-window.lib" )
#pragma comment( lib, "sfml-graphics.lib" )
#else  // Debug build
#pragma comment( lib, "sfml-system-d.lib" )
#pragma comment( lib, "sfml-window-d.lib" )
#pragma comment( lib, "sfml-graphics-d.lib" )
#endif
Hope this was helpful.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 3790
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Can someone help me set up SFML?

Post by albinopapa » August 11th, 2019, 5:49 am

Also, the only times I get the -2 at the end is on .dll files, but not the .lib files.

The .dll files are for runtime, when your program is actually running. The .lib files are used during compilation, to build your program. So you want to link to the .lib files when building/compiling.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

TheCollector
Posts: 41
Joined: August 1st, 2019, 9:57 pm

Re: Can someone help me set up SFML?

Post by TheCollector » August 13th, 2019, 5:44 pm

It works!!! Thank you. That helped a lot.

Post Reply