sfml and VC++ help

Has anyone used sfml with VC++ 2010 express?

I am having trouble getting it installed properly. I have followed the tutorial twice now and always the same result. :(
closed account (NUj6URfi)
Which tutorial and what are your errors?
closed account (3qX21hU5)
Is it the same error codes as in the other thread? If so could you provide me a few screenshots?

1 - Screenshot of your C++ General Page (The additional include directories)

2 - Screenshot of your Linker General Page (Additional Library Directories)

3 - Screenshot of your Linker Input Page (Where you put in sfml-graphics-d.lib ect.) both release and debug mode.

4 - Screenshot of the lib folder in your SFML download (Want to make sure that there is actually a 2 in the file name)

5 - Screenshot of the folder where your programs .exe file is.


Also could you answer these questions?

1 - Did you make sure to download the compiled version for VS2010 and not a different one?

2 - Are you linking statically or dynamically?

3 - Could you paste all error codes you have gotten?
alright that is a lot so let me see what info I can give you...
There are only a few things that need to be set to get SFML to work with VS.
NOTE: You will need to do this twice, once each for release and debug builds.

Open the project properties. Under Configuration properties -> VC++ directories set the include and library directories to the coresponding directories in your SFML root directory.

Then under Linker -> general add SFMLs lib directory to the additional library directories

Then Linker -> input add the sfml libs:

I link statically so for debug build add
sfml-system-s-d.lib
sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-network-s-d.lib
sfml-audio-s-d.lib
and
sfml-system-s.lib
sfml-graphics-s.lib
sfml-window-s.lib
sfml-network-s.lib
sfml-audio-s.lib
for releas builds to the additional dependencies.
For dynamic linking just remove the -s from the library names.

To link statically go to C/C++ -> code generation change runtime library from MD to MT for release and MDd to MTd for debug. Also add SFML_STATIC to preprocessor definitions under C/C++ -> Preprocessor.

Hopefully I didn't miss anything.
Last edited on
closed account (3qX21hU5)
One thing to add to naraku's post. Don't forget to add sfml-main-d.lib and sfml-main.lib to the linker which will allow you to use int main(). Otherwise if you follow them steps completely and still get errors you will need to compile the sources to get a version that is compatible with your compiler. Which is quite easy to do with CMake and using the tutorials available.
Here is the exact error I get...

------ Build started: Project: sfml junk 1, Configuration: Debug Win32 ------
C:\Program Files\Microsoft Visual Studio 10.0\SFML-2.1\bin\sfml-system-d-2.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2E8
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I think I have it installed correctly, but it still won't work. I may try to download a different version.
closed account (NUj6URfi)
Shouldn't this be under windows programming?
closed account (o1vk4iN6)
sfml-system-d-2.dll : fatal error LNK1107

The compilation shouldn't be aware of .dll files, you link to .lib files and when the program runs it looks for the associated .dll file. I'd double check that you didn't accidentally put a .dll somewhere in your options.
Last edited on
closed account (NUj6URfi)
Also make sure your dlls are next to your program code files.
Or save yourself and your users a world of trouble and just statically link the lib. Dynamic linking on Windows sucks.

I go through the entire process of setting this up in excruciating detail in this post:

http://www.cplusplus.com/forum/beginner/95295/#msg511542



(EDIT: I should clarify... dynamic linking does have merits, but for small scale indie projects they don't apply and/or aren't worth it)
Last edited on
well xerzi you were right about the .dll in the linker. So I fixed that but now I am back to my original problem.

It says DLL files can't be found.

So, I will try Disch's plan next. Also, appoligies to toad, this probably should have gone into window forum.
closed account (3qX21hU5)
It says DLL files can't be found.


Because you didn't place your .dll files in the correct spot most likely. To solve this would be to either link statically (By following Disch's recommendation) which is probably the best way to go about it for small projects, or to go into the SFML folder and copy the .dll files you are using into your projects folder where your projects .exe resides.


Here is from the SFML tutorial right at the bottom (I can see how it is missed)

Now compile the project, and if you linked to the dynamic version of SFML, don't forget to copy the SFML DLLs (they are in <sfml-install-path/bin>) to the directory where your compiled executable is. Then run it, and if everything is ok you should see this:
Last edited on
Thank you all for your patience and guidence. My sfml works! I can hardly wait to learn it but first I must get drunk...

Such a to do...
Topic archived. No new replies allowed.