Tag Archives: c++11

error: ‘to_string’ is not a member of ‘std’

I cross-compiled DRonecode – SDK with Hsi’s ARM-HisiV300-Linux-G ++ and reported the error

 error: 'to_string' is not a member of 'std'

Arm-hisiv300-linux-g ++ is c++11 supported, header < string> Also included. Again, error.
Search baidu, it is said that + -std=c++11, but I have added this, still not good, then read a post said that because the tool chain itself does not use the standard c++11 library, resulting in the compilation,
Solution: A Cmakelists. TXT needs to add the following options; The same goes for makefile files;

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-D_GLIBCXX_USE_C99=1)

 

Error: unrecognized command line option “-std=c++11”, to solve the problem that ubuntu does not support c++11

The cause of this compilation error is not high enough in the g++ GCC version.
Add the source

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test

$ sudo apt-get update

Install version 4.8

$ sudo apt-get install gcc-4.8 g++-4.8

View the local installation version

$ ls -lh /usr/bin/g++*

You should see that 4.6 and 4.8 are shipped.
Switch version

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

$ sudo update-alternatives --config gcc

here select version 4.8 serial number
Check the g++ version again

$ g++ --version

Confirm that the current version is 4.8, the problem has been solved!
From: http://my.oschina.net/chenyoca/blog/226455