• 11
• 9
• 10
• 9
• 10

# Problem when compiling SFML game with Code::Blocks

This topic is 967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Whenever I try to compile my SFML game with Code::Blocks I get this weird error:

||=== Build: Debug in Test (compiler: GNU GCC Compiler) ===|
C:\Program Files\SFML-2.3.1\lib\libsfml-system-s-d.a(String.cpp.obj)||In function ZNKSbIjSt11char_traitsIjESaIjEE8_M_checkEjPKc':|
C:\Dev\MinGW32-PosixDwarf492r2\i686-w64-mingw32\include\c++\bits\basic_string.h|324|undefined reference to std::__throw_out_of_range_fmt(char const*, ...)'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| 

I also have defined SFML_STATIC.

I really don't know why I'm getting that error, help please?

Edited by louie999

##### Share on other sites

Ok, well, how can I update/upgrade my GCC compiler ?

The "Mark for Upgrade" thing is not available. Any ideas ? :S

##### Share on other sites

Ok, well, how can I update/upgrade my GCC compiler ?

The "Mark for Upgrade" thing is not available. Any ideas ? :S

##### Share on other sites

I think I fixed that problem, I just had the wrong build options. But, on to the next problem...

##### Share on other sites

That's exactly the same problem, except you apparently changed from static linking to dynamic linking. All your changed build option did was to move the error from compile time to run time.

SFML is trying to call a function that is missing in your version of the standard library. The first step when you get linker errors about stuff being undefined is to copy paste the error (or at least the symbol it complains about) into a search engine (unless you already know which library or source file contains the missing code). All results are the same: you need at least GCC 4.9.

From the fact you HAVE SFML libraries and the error you see now, I would assume you didn't build SFML yourself and just grabbed some pre-built binaries. Those were built with a newer version of GCC and the simplified issue is: it's not compatible with yours (technically the problem is more with the different standard library versions).

Since you're on Windows anyway and struggling with very common compiler/linker errors: why are you adding the extra pain and complexity of using an IDE that uses MinGW instead of some Visual Studio Express or Community version? Dealing with the extra issues from potentially outdated GNU ports for Windows is not something I'd do without a very good reason.

##### Share on other sites

That's exactly the same problem, except you apparently changed from static linking to dynamic linking. All your changed build option did was to move the error from compile time to run time.

SFML is trying to call a function that is missing in your version of the standard library. The first step when you get linker errors about stuff being undefined is to copy paste the error (or at least the symbol it complains about) into a search engine (unless you already know which library or source file contains the missing code). All results are the same: you need at least GCC 4.9.

From the fact you HAVE SFML libraries and the error you see now, I would assume you didn't build SFML yourself and just grabbed some pre-built binaries. Those were built with a newer version of GCC and the simplified issue is: it's not compatible with yours (technically the problem is more with the different standard library versions).

Since you're on Windows anyway and struggling with very common compiler/linker errors: why are you adding the extra pain and complexity of using an IDE that uses MinGW instead of some Visual Studio Express or Community version? Dealing with the extra issues from potentially outdated GNU ports for Windows is not something I'd do without a very good reason.

I don't think I changed to dynamic linking tho, as the SFML_STATIC was defined (?)

Edit: wait I did g++ --version and got this:

I have 4.9.2 but the error is still happening :(

Edited by louie999

##### Share on other sites

The problem is most likely: You downloaded the wrong/incompatible package from the SFML website.

Go back there and download the package compatible with your compiler or even better, learn to compile the library yourself (then its automatically compatible).

http://www.sfml-dev.org/faq.php#build-environment

##### Share on other sites

The problem is most likely: You downloaded the wrong/incompatible package from the SFML website.

Go back there and download the package compatible with your compiler or even better, learn to compile the library yourself (then its automatically compatible).

http://www.sfml-dev.org/faq.php#build-environment

##### Share on other sites

Your screenshot shows MinGW-W64 (thats the project name of the most up to date fork) and the download website says MinGW. You could ask in SFML forum, if you need to know which distribution they used exactly, but IIRC their preferred answer is "learn to compile yourself".

Btw., you might want to use the 64bit SEH version of MinGW-W64 if you have a 64bit OS, as DW2 got some problems on Windows if you throw through a callback compiled with a different compiler and SJLJ adds exception setup code to most functions.

Edited by wintertime