Beginning and how to set up SFML 2.0/1.6

Started by
5 comments, last by JustAnotherTroll 11 years ago

Hey,

I always wanted to learn game programming and this is not my first try to learn it :)

I decided to use C++ because I completed an apprenticeship where I learned c/c++ but only worked with MCU's. (most of the time i used C to programm everyhing).

But theres one point I always fail and that is to setup the compiler with all the libararies and stuff.

I decided to use SFML for 2D programming to start off :) but after 2 days of work i cant get it to work properly... I tried SFML 1.6 and SFML 2.0 and both won't work.

I tried to set it up for Visual Studio 2012 and for Visual C++ 2010.

At the moment I was able to compile the program but ONLY in Release mode. When I compile it in debug mode i can't execute it because the "sfml-graphics-d-2.dll" is missing. BUT i checked the folder and it is NOT missing... It is in the lib directory of SFML.

I tried to use static libararies but that won't work at all.. i can't even compile because i get several errors like this one:

"Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s-d.lib(Color.obj) Project2"

I hope you can help me with my problem :)

Advertisement
Under normal circumstances the DLL loading happens as described in the remarks of the LoadLibrary documentation.

That means you will usually have to ensure manually that any DLLs needed will be next to the executable or in the working directory (exact details will depend a lot on how the project is set up). Having details in some libraries lib folder is practically always insufficient.

It's been some time since I used SFML but I definitely could do it while linking statically. The documentation will help there, usually you just have to set a #define to notify the library.

Your .dll files need to be in the same folder from which your .exe is run, not in the lib folder of sfml.

Also there are some differences between debug and release project configuration when setting up SFML2 (by the way I strongly recommend you go with SFML2 in case you had any doubts)

There's some really good tutorials written by Laurent himself here: http://www.sfml-dev.org/tutorials/2.0/start-vc.php (including what you need to do if you want to link the libraries statically - look towards the bottom)

Thanks for the fast answers :)

I didn't know that you have to put the .dll files in the same folder (seems logic) :D

So that works for now :)

(by the way I strongly recommend you go with SFML2 in case you had any doubts)

Why would you recommend SFML 2.0? On the page it says it's still a beta. But i used it anyways :)

So if i build the static libs (CMake -> checking SFML_USE_STATIC_STD_LIBS and unchecking BUILD_SHARED_LIBS -> building -> adding SFML_STATIC at the preprocessor and change the input to sfml-xxxx-s) i still get errors when i want to compile the testprogram :(

Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Shape.obj) Project2
Error 2 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(RenderWindow.obj) Project2
Error 3 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Color.obj) Project2
Error 4 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(RenderStates.obj) Project2
Error 5 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(CircleShape.obj) Project2
Error 6 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(RenderTarget.obj) Project2
Error 7 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Transform.obj) Project2
Error 8 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Transformable.obj) Project2
Error 9 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(VertexArray.obj) Project2
Error 10 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Texture.obj) Project2
Error 11 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Image.obj) Project2
Error 12 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(View.obj) Project2
Error 13 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(Shader.obj) Project2
Error 14 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(GLCheck.obj) Project2
Error 15 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(TextureSaver.obj) Project2
Error 16 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-graphics-s.lib(ImageLoader.obj) Project2
Error 17 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(Window.obj) Project2
Error 18 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(VideoMode.obj) Project2
Error 19 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(GlContext.obj) Project2
Error 20 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(WindowImpl.obj) Project2
Error 21 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(VideoModeImpl.obj) Project2
Error 22 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(WglContext.obj) Project2
Error 23 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(JoystickManager.obj) Project2
Error 24 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(WindowImplWin32.obj) Project2
Error 25 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-window-s.lib(JoystickImpl.obj) Project2
Error 26 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-system-s.lib(String.obj) Project2
Error 27 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-system-s.lib(Err.obj) Project2
Error 28 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\sfml-system-s.lib(ThreadLocal.obj) Project2
Error 29 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(locale0.obj) Project2
Error 30 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(ios.obj) Project2
Error 31 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(iosptrs.obj) Project2
Error 32 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(locale.obj) Project2
Error 33 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(xlock.obj) Project2
Error 34 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(xthrow.obj) Project2
Error 35 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(wlocale.obj) Project2
Error 36 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(xlocale.obj) Project2
Error 37 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Main.obj d:\cpp\Projects\Project2\Project2\libcpmt.lib(xdateord.obj) Project2

I have no clue what that means :D

Why would you recommend SFML 2.0? On the page it says it's still a beta. But i used it anyways

SFML 2 is only technically in beta. In reality, all functionality it has, has been finalized, and pretty much all bugs have been worked out. Yes, there are bugs, but honestly, there are less bugs than sfml1.6. The reason SFML2 is not officially released yet, and the only thing holding the official release is the full write-up of tutorials. (see https://github.com/LaurentGomila/SFML/wiki/FAQ#wiki-grl-version for a more detailed answer, and then this: https://github.com/LaurentGomila/SFML/issues?milestone=5&page=1&state=open will show you that the ONLY remaining task for the SFML2 milestone is the tutorials and some documentation)

Anyway, onto your bug. You have to define SFML_STATIC in your own projects config settings if you're using the statically linked libs. Also, have you linked to sfml-system? I think I saw a post on their forums for that at one time... Which by the way, if you're having SFML specific questions (and we can't help you here) you may also try the official forums: http://en.sfml-dev.org/forums/index.php )

On the forums there is a nightly build of SFML 2.0 it's in great shape, much better than the RC on the front page. Get that version, also 2.0 has a tutorial for setting up sfml on the website as well as very good documentation.

The page with 2.0 pre built

http://en.sfml-dev.org/forums/index.php?topic=9513.0

Tutorials for 2.0

http://www.sfml-dev.org/tutorials/2.0/

Documentation for 2.0

http://www.sfml-dev.org/documentation/2.0/modules.php

If this post or signature was helpful and/or constructive please give rep.

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

// Easy to learn 2D Game Library c++

SFML2.2 Download http://www.sfml-dev.org/download.php

SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/

// Excellent 2d physics library Box2D

http://box2d.org/about/

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

Atm. i have graphics,window and system included and SFML_STATIC is in the Preprocessor Defenitions.

Maybe I made a mistake while building the library's....

On the forums there is a nightly build of SFML 2.0 it's in great shape, much better than the RC on the front page

What is a nightly build? And what's it diffrent from the one at the original site?

Btw are there any other tutorial sites? Because i'm really a total newbie at WIN Api, FSML, game programming and stuff so i need some easy steps to follow (Well i know the basics of message loops and so on) :)

This topic is closed to new replies.

Advertisement