The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Lazy Foo SDL tutorial 33 won't compile in codeblocks 13.12
shinn497


Joined: 26 Jan 2014
Posts: 14
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()'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**)'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?
Lazy Foo SDL tutorial 33 won't compile in codeblocks 13.12
javierecf


Joined: 21 Feb 2014
Posts: 52
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
Quote:
#include <string>



2014-03-16 0:56 GMT-07:00 shinn497:
Quote:
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()'
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**)'
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
Javier Flores
shinn497


Joined: 26 Jan 2014
Posts: 14
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.
Lazy Foo SDL tutorial 33 won't compile in codeblocks 13.12
javierecf


Joined: 21 Feb 2014
Posts: 52
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: http://www.cplusplus.com/forum/beginner/120836/



2014-03-16 1:42 GMT-07:00 shinn497:
Quote:
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
Javier Flores
Lazy Foo SDL tutorial 33 won't compile in codeblocks 13.12
Jonny D


Joined: 12 Sep 2009
Posts: 932
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
jungletek


Joined: 30 Oct 2011
Posts: 4
I posted this in a newer thread about the same issue, it's sad that people never follow up with their solutions on the internet...

Quote:
I believe this is a combination of a MinGW bug (update MinGL to a newer version), and a bug/error(?) with Lazy Foo's code.

Changing all instances of '_Longlong' to 'long long' causes the code to compile properly, and the executable seems to perform as expected, as far as I can see. If anyone can let me know if this is in some way an incorrect solution, I'd love to hear it as I'm still very much in the process of learning.

Also make sure you're compiling for the c++11 standard, using the proper compiler flags.