龙芯中标麒麟7.0环境中c++程序如何使用codecvt?

龙芯中标麒麟7.0上依照c++11标准编译(-std=c++11)使用codecvt的很小的c++无界面程序报如下错误,在下c++功底太差,敬请各位大佬指教,

In function ‘int main(int, char**)’:
error: ‘wstring_convert’ was not declared in this scope
  wstring_convert<codecvt_utf8<char32_t>, char32_t> cv;
  ^
error: ‘codecvt_utf8’ was not declared in this scope
  wstring_convert<codecvt_utf8<char32_t>, char32_t> cv;
                  ^
error: expected primary-expression before ‘char32_t’
  wstring_convert<codecvt_utf8<char32_t>, char32_t> cv;
                               ^
error: ‘cv’ was not declared in this scope
    auto str32 = cv.from_bytes(line);
                 ^
error: unable to deduce ‘auto&&’ from ‘str32’
    for(auto c : str32)
                 ^

源文件:
#include <iostream>
#include <fstream>
#include <string>
#include <locale>
//#include <codecvt> //No such file or directory in Neokylin7.0(Loongson)
//#include <codecvt.h> //No such file or directory in Neokylin7.0(Loongson)
//#include <bits/codecvt> //No such file or directory in Neokylin7.0(Loongson)
#include <bits/codecvt.h>

源文件主体在此省略,旨在使用codecvt获得非汉语,非英语utf8文本文件中字符串的十六进制unicode码位(code point).

分别使用注释的3个include语句导致找不到对应文件的错误,使用<bits/codecvt.h>导致错误如上所示。

find / 到下面两个codecvt相关文件:
/usr/include/c++/4.9.3/bits/codecvt.h
/usr/include/c++/4.9.3/ext/codecvt_specializations.h
虽然搜索到boost的几个相关文件,但暂不想使用boost。
 编译器: g++ (GCC) 4.9.3 20150626 (NeoKylin 4.9.3-3)
是龙芯中标麒麟7.0的编译器不完全支持c++11导致的吗?
源文件拷贝到ubuntu18.04上#include <codecvt>
编译(-std=c++11)无误。

怎么在龙芯中标麒麟7.0环境中编写c++程序使用codecvt?
已邀请:

water

赞同来自: worker

换高一点版本的工具链吧,loongnix 上有 gcc7 ,用loongix 的源(http://ftp.loongnix.org/os/loongnix/1.0/fedora.repo)在中标7 上安装一下 devtoolset-7 这个包。
gcc7 里面有 codecvt.h 这些头文件,对c++11 支持的更完善
 
devtoolset-7 默认安装到 /opt/rh/devtoolset-7 目录了
[root@localhost loongson]# yum install devtoolset-7
[root@localhost loongson]# source /opt/rh/devtoolset-7/enable 
[root@localhost loongson]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/mips64el-redhat-linux/7/lto-wrapper
Target: mips64el-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-extra-sgxxlite-multilibs --with-odd-spreg-32=no --with-system-zlib --cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-mips64el-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-long-double-128 --with-arch=mips64r2 --with-abi=64 --build=mips64el-redhat-linux
Thread model: posix
gcc version 7.3.1 20180303 (Red Hat 7.3.1-6) (GCC) 
 
 
 
 

要回复问题请先登录注册