Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem when compiling SFML game with Code::Blocks

Started by louie999 Aug 26, 2015 at 9:36 AM 12 replies 5.2k views
Original Post
louie999
louie999

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)) ===| 

Here is my linker settings:

pEMe6qS.png

I also have defined SFML_STATIC.

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

louie999
louie999

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

qyrM1Q9.png

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

georger.araujo
georger.araujo

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

qyrM1Q9.png

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

Download and install the 32-bit bundle of TDM-GCC.

louie999
louie999

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

afOk2yn.png

Trienco
Trienco

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.

f@dzhttp://festini.device-zero.de
louie999
louie999

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:

YNyGs78.png

I have 4.9.2 but the error is still happening :(

wintertime
wintertime

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

louie999
louie999

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

Huh, but I downloaded the GCC 4.9.2 MinGW(DW2) - 32-bit in the SFML download page.Maybe I can try to build/compile the library...

wintertime
wintertime

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.

louie999
louie999

Problem solved, I got it to work without linker errors but then when I try to run the .exe of my game it says something about entry point not found in libstdc++-6, so I copied the libstdc++-6 in the mingw bin folder to my System32 then it works :D

Servant of the Lord
Servant of the Lord

Problem solved, I got it to work without linker errors but then when I try to run the .exe of my game it says something about entry point not found in libstdc++-6, so I copied the libstdc++-6 in the mingw bin folder to my System32 then it works biggrin.png

Copy it to your program's directory, not to your System32 directory.

You shouldn't ever copy anything to your System32 directory.

Alternatively, you could add your mingw bin folder to your system %PATH%.

Huh, but I downloaded the GCC 4.9.2 MinGW(DW2) - 32-bit in the SFML download page.Maybe I can try to build/compile the library...

[MinGW] [4.9.2] [DW2/SJLJ] [32bit/64bit] [static/dynamic] [single-threaded/multi-threaded] [debug/release]

Each of those matter. If even one is different between your executable and the library you are trying to use, it might fail to work work.

Mixing debug/release usually works but sometimes doesn't, and many versions of MinGW are compatible with each other until they change stuff too much internally, but you need to know that it might fail.

DW2 and SJLJ are incompatible compile settings, 32bit vs 64 bit are, and static and dynamic usually are. These ones are often caught when trying to compile.

That's why it's usually easier to compile the libraries yourself. Depending on the library, this can be a pain, though!

When I update or change my compiler settings, if my project is no longer compatible, I pretty much have to spend the whole day recompiling a bunch of different libraries (two of them take multiple hours to compile each). But that only happens once or twice a year.

louie999
louie999

@Servant of the Lord Oops, ok I'll copy it to game's directory. :)

wintertime
wintertime

If you only use one MinGW and might have more than one project, the better solution is adding MinGW/bin to the path.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.