Installation Blues: SFML

I'm trying to follow the installation instructions on the SFML site, but no matter what I do I get an error. I'm using Code::Blocks with GCC MINGW.

http://www.sfml-dev.org/tutorials/2.1/start-cb.php This is the link to the tutorial.
Last edited on
What error?
Maybe you set the wrong libraries in the linker settings? For example: The release version of the libraries for debug. Please post the error you get :).
Could you give us your error code that way we can know the exact nature of the problem? Without it we are just guessing at best.

Though some helpful tips would be.

1. - Like stormboy mentioned make sure when you are linking against the libraries that you link the correct version (Debug mode should link against the debug version of the library files which means the ones that have -d in them, whereas release mode should link against the release version).

2 - If you are dynamically linking the libraries make sure you include the .dll files in your project. Each IDE I believe has a different policy on where to put them, I am not sure about Code::Blocks but Visual Studio you place then in the same folder as your executable (Again make sure to place debug versions with debug exec and release versions with release exec).

3 - If you are statically linking the libraries (Using the libraries with a -s in the name) make sure you defined SFML_STATIC in your preprocessor.

4 - Triple check that you are pointing to the correct include directory, you are pointing to the correct library directory, all your linking is correct for the library names (The order does matter! For the the release build you should go sfml-graphics, sfml-window, sfml-system, sfml-main1 in that order if you only need the basics (IE no sound and networking)). Basically triple check everything.

5 - If all else fails you might be using a different version (Or some other problems that can happen) of GCC MINGW then the precompiled binaries of the SFML libraries. In which case you will need to download the sources and compile them yourself. I know this sounds daunting and challenging but it is actually quite easy since SFML uses CMAKE. All you need to do is download the SFML sources and get CMAKE, run the CMAKE GUI to generate a project file for Code::Blocks and then open that project and compile the release and debug versions.

There is also plenty of tutorials out there that walk you through compiling SFML and other libraries from their source with CMAKE.

But anyways hopefully that helps a bit but again I am just guessing out of the blue since we don't know your exact problem without a error code.


1 - sfml-main is used so you can use the standard int main() entry point in your applications.
Also, I'd like to point out that there are different 'variants' of the MinGW GCC compiler. Its given in the red box on the tutorials:
SFML Tutorials wrote:

There are multiple variants of gcc for Windows, which are incompatible with each other (different exception management, threading model, etc.). Make sure that you pick up the right package according to the version that you use. If you don't know, check which of the libgcc_s_sjlj-1.dll or libgcc_s_dw2-1.dll file you have in your MinGW/bin folder. If you're using the version of MinGW shipped with Code::Blocks, you probably have a SJLJ version.


So make sure you got the correct library.

If you have the "DW2" version: Get the MinGW one.
If you have the "SJLJ" version: Get the TDM-GCC one.
CodeGazer: I didn't think to add them to my project, or think at all really, thanks for mentioning that.

Stormboy: As to your last reply, I did read those and I am running the DW2. As for the former, I am at a school computer right now, but I'll upload the error as soon as I get home, but I think it's just that I didn't include the files in my project.
Code::blocks by default uses TDM-GCC so I would uninstall and get the SJLJ instead of DW2.
OK, so I installed the SJLJ, redid the tutorial, and now it won't even compile! I followed the tutorial to the tee, but it won't work! Well, I suppose if I did it right it'd work, so I must be doing something wrong, I just don't have the slightest clue as to what. Here's the Build Messages:

||=== SFML, Debug ===|
obj\Debug\main.o||In function `main':|
C:\Users\Dave\Documents\C++\SFML\main.cpp|5|undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|5|undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|6|undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|7|undefined reference to `_imp___ZN2sf5Color5GreenE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|7|undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|15|undefined reference to `_imp___ZN2sf6Window5closeEv'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|12|undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|18|undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|18|undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|19|undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|19|undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|20|undefined reference to `_imp___ZN2sf6Window7displayEv'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|9|undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
C:\Users\Dave\Documents\C++\SFML\main.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
obj\Debug\main.o||In function `ZN2sf11CircleShapeD1Ev':|
C:\ProgrammingUtilities\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
C:\ProgrammingUtilities\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
C:\ProgrammingUtilities\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
||=== Build finished: 20 errors, 0 warnings (0 minutes, 5 seconds) ===|
Last edited on
You may have linked them in the wrong order. Also are you statically or dynamically linking? If you are statically linking you may have forgot to include the static macro SFML_STATIC
I'm using the dynamic, and I have the 'graphics, window, system' order it says.
Make sure you have specified the correct paths according to where you the files when adding the additional compiler and linker search directories.

Also, make sure that you are not configuring for debug mode but not release mode and then compiling in release mode or vice versa.
Topic archived. No new replies allowed.