c++11?

Pages: 12
using codeblocks trying to get c++11 standards... not working so well.

i'm attempting to use to_string. i get the error "to_string is not a member of std"

I have used -std=c++11 under compiler flags and it's still the same results. Im using GNU gcc compiler (that's the default with my code blocks)

I'm running the code from the reference off this site - http://www.cplusplus.com/reference/string/to_string/

and that's what i get. I've also tried using it in a current project and same results. iostream and string is included (i heard somewhere #include <memory> could help but is didn't). I have also tried 0x's standards. (-std=c++0x) I don't know what else to try, any help is appreciated.
Are you on Windows using MinGW? I remember stuff like that being a problem.

What version of g++ do you have?
I searched google and this patch might help http://tehsausage.com/mingw-to-string (Though I won't be able to help if something goes wrong here ;p)

Edit: On GCC 4.9.1, I don't have a problem with to_string, so I would suggest updating your compiler. CodeBlocks makes this relatively easy to link.
Last edited on
It could be possible that the g++ version you have is out of date. What OS are you using?
Oh yeah sorry, im on windows 7.using MinGW . I had thought this might be the problem and went to mingw's site and downloaded the mingw-get-setup which i just went under the assumption that this would give me the most recent version of gcc. (installed to codeblocks, same results.) so apparently that's how you not get the latest version. if you think that would be the problem. where is the link to the most recent version, that's all that i found on the site >.< edit: ill try Ganado's post first
Last edited on
Can you see what version of gcc you're using? Try using cmd and cd to the directory that you have g++.exe in, and then type g++ --version
It most likely did give you the right version, but codeblocks comes with its own mingw version that is out of date. So the version you downloaded from their site would have to replace codeblock's version, or have its directoried pointing to the new mingw version's gcc and g++
Can you see what version of gcc you're using?
4.8.1
Actually crimsonzero2, the mingw website seems kinda outdated. I could be wrong.

Edit: Didn't see your latest post.
Just to be sure, when you go in Code Blocks and then Compiler Settings -> Toolchain executables, the "Compiler's installation directory" is your updated one correct?

If it is, then I'm not really sure what the problem is.

Here's personally what I use, dark ninjuh
http://nuwen.net/mingw.html (GCC 4.9.1)

Another edit: It seems even as of 4.8.2, it isn't going to work on MinGW
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59076
so 4.8.1 isn't going to work either with to_string

Yeah... this must be frustrating for you, it's annoying I'm sure. Apparently the patch I posted earlier should still work for 4.8.2 as well though.
Last edited on
Just to be sure, when you go in Code Blocks and then Compiler Settings -> Toolchain executables, the "Compiler's installation directory" is your updated one correct?

yeah because i just replaced what was in it's default MinGW folder with the ones i had updated. which is 4.8.1 so that way i didnt have to configure new paths.
Yeah... this must be frustrating for you, it's annoying I'm sure.
yeah, was quite the roadblock in my current project. ill attempt to just get the 4.9.1 , the new features help anyways.
Edit: "My MinGW distribution ("distro") is x64-native" from - http://nuwen.net/mingw.html

64 bit,? im on 32 at the moment, if this means 64 bit(im assuming thats what that means) then its pointless trying to get that 4.9.1.can someone confirm am i correct on that's what there saying. unless he's just reffering to his MinGW and the gcc is 4.9.1 and possibly cross compatible in 32 and 64, the download is "mingw-12.1" should i just extract that somewhere and take the gcc files out and put them in mine?

edit2: i'm just trying that and hoping that the gcc in his MinGW happens to be 32 (with precautious backup measures taken of course) will get back to posting results after its done extracting.
Last edited on
hum, not sure if my link is compatible with 32-bit windows. That's all I got, wish I could help more.. good luck.
Yeah the gcc there is 64 bit . This roadblock of steel. if anyone comes up with any other solutions at all please post.I will post a solution if i find one.
edit:fogot to post that the http://tehsausage.com/mingw-to-string patch gonado originaly posted did not work . (properly installed, same error)
Last edited on
Uhh, re-download codeblocks with the mingw package?

Try to use command line to make sure this is a problem with codeblocks instead of mingw,
-Open a random folder
-make a basic c++11 .cpp file
-shift right click on the folder and "open command window here"
-do:
PATH=C:\Program Files (x86)\CodeBlocks\MinGW\bin
(or if you use 32bit, there is no (x86))
-do:
g++ -o -std=c++11 test.cpp test 

-open test.exe
Uhh, re-download codeblocks with the mingw package?

Try to use command line to make sure this is a problem with codeblocks instead of mingw,
-Open a random folder
-make a basic c++11 .cpp file
-shift right click on the folder and "open command window here"
-do:
PATH=C:\Program Files (x86)\CodeBlocks\MinGW\bin
(or if you use 32bit, there is no (x86))
-do:
g++ -o -std=c++11 test.cpp test

-open test.exe

had some problems compiling out side of the g++ directory so i just added "test.cpp" in MinGW/bin and compiled from there. it compiled. but g++ gave the same error. so yeah its mingw not codeblocks .-. .. thanks though that did narrow it down a little :) atleast i know its g++ thats the problem and not my code blocks config
Last edited on
though still no solution, anyone can still pitch in in anyway if they can.
i am using orwell dev C++ in windows 7, because its syntax highlighting is much better than codeblocks, also in my pc exe made by codeblocks are often blocked by avast antivirus.
in dev C++ you can set 11 standard by,
tools > compiler option > setting > code generation > in language standard (-std) select ISO C++ 11
yeah because i just replaced what was in it's default MinGW folder with the ones i had updated.
I hope you deleted content first and then unpacked new and not just unpacked replacing anything which happens to have same name.

I suggest to delete everything and make a clean install of MinGW (preferrably 4.9.1).

EDIT:
exe made by codeblocks are often blocked by avast antivirus.
You do know that IDE does not make executables, compiler does. And both code::blocks and dev-C++ uses gcc as compiler?
in dev C++ you can set 11 standard by,
In C::B too, but it still wouldn't help you, as idea was to use compiler directly without IDE to exclude possible IDE configuration problem.
Last edited on
I hope you deleted content first and then unpacked new and not just unpacked replacing anything which happens to have same name.

yeah i did delete first

I suggest to delete everything and make a clean install of MinGW (preferrably 4.9.1).

if you can find the windows 32 bit version of this i would be greatly appreciative.
Last edited on
This is it:
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.1/threads-win32/dwarf/
sigh..................... literally just compiled directly from that g++ and got the error. thats impossible its 4.9.1 , i did not use code blocks i compiled using g++ commands. Seriously what's going on. can someone test this? download it and run the g++ straight from there using the to_string example it has to be something funked in my computer.
edit: also running g++ --version in that folder does in fact return 4.9.1 like its supposed to. I have no idea whats up with this
Last edited on
Pages: 12