Lazy Foo SDL tutorial 33 won't compile in codeblocks 13.12

I’m trying to compile the files exactly as given but I get the following errors:

||=== Build: Debug in test2.0proj (compiler: GNU GCC Compiler) ===|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp||In function ‘bool loadMedia()’:expressionless:
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|378|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|378|error: ‘_Longlong’ was not declared in this scope|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|381|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|381|error: expected ‘)’ before ‘gData’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp||In function ‘int SDL_main(int, char**)’:expressionless:
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|479|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|479|error: ‘_Longlong’ was not declared in this scope|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|487|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|487|error: expected ‘)’ before ‘gData’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|493|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|493|error: expected ‘)’ before ‘gData’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|501|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|501|error: expected ‘)’ before ‘gData’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|507|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|507|error: expected ‘)’ before ‘gData’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|513|error: ‘to_string’ is not a member of ‘std’|
C:\game dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|513|error: expected ‘)’ before ‘gData’|
||=== Build failed: 16 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

In particular, “to_string is not a member of std” is concerning me. I googled it and it says that this is a problem with mingw but I’m using the most recent version of code::blocks which should therefore have the most recent mingw. What could I do to make this work?

dont be just copying and pasting demos and tutorials from the internet,
read about SDL, c++ and its libraries.
and if you are going to use a tutorial, a tip: write everyline of code of
the tutorial on your own. that way at least you have some kind of sense of
what the program is doing.

also be sure you have

#include

2014-03-16 0:56 GMT-07:00 shinn497 :> I’m trying to compile the files exactly as given but I get the following

errors:

||=== Build: Debug in test2.0proj (compiler: GNU GCC Compiler) ===|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp||In
function ‘bool loadMedia()’[image: Neutral]
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|378|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|378|error:
‘_Longlong’ was not declared in this scope|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|381|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|381|error:
expected ‘)’ before ‘gData’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp||In
function ‘int SDL_main(int, char**)’[image: Neutral]
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|479|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|479|error:
‘_Longlong’ was not declared in this scope|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|487|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|487|error:
expected ‘)’ before ‘gData’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|493|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|493|error:
expected ‘)’ before ‘gData’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|501|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|501|error:
expected ‘)’ before ‘gData’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|507|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|507|error:
expected ‘)’ before ‘gData’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|513|error:
‘to_string’ is not a member of ‘std’|
C:\game
dev\33_file_reading_and_writing\33_file_reading_and_writing\33_file_reading_and_writing.cpp|513|error:
expected ‘)’ before ‘gData’|
||=== Build failed: 16 error(s), 0 warning(s) (0 minute(s), 0 second(s))
===|

In particular, “to_string is not a member of std” is concerning me. I
googled it and it says that this is a problem with mingw but I’m using the
most recent version of code::blocks which should therefore have the most
recent mingw. What could I do to make this work?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Javier Flores

The tutorial isn’t explained. It is just source. Normally I can figure out what works and what doesn’t this way if I know it will compile.

also codeblocks uses a version of mingw really outdated and with a lot of
bugs, check out http://mingw-w64.sourceforge.net/, is better.
somebody explained it here: stoi and c++ 11 - C++ Forum

2014-03-16 1:42 GMT-07:00 shinn497 :> The tutorial isn’t explained. It is just source. Normally I can figure

out what works and what doesn’t this way if I know it will compile.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Javier Flores

std::to_string() also happens to be a C++11 feature. You have to turn on
C++11 support explicitly for your compiler. Use the compiler flag
-std=c++11 or -std=gnu++11.

Jonny D