On 28 June 2011 00:31, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > On 28 June 2011 00:04, eric wrote: >> >>> You need to configure gcc with --enable-clocale=gnu and reinstall it. >>> >>> That should be the default on GNU/Linux but apparently your system is >>> missing something necessary to support named locales. >> >> so I do >> ./configure --enable-clocale=gnu > > (You obviously didn't read the installation docs, you're not supposed > to run ./configure in the source directory) > > Did it actually enable the gnu locale model? You might need to check > $TARGET/libstdc++-v3/config.log or compare which header files are > installed. Noone can tell if you have the GNU locale model installed > successfully. > > Or why don't you just install gcc from Ubuntu's package manager? > Surely GCC 4.5 is available? > Actually you probably do have the GNU locale code installed, I missed that you can get the same error from the GNU model: void locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, __c_locale __old) { __cloc = __newlocale(1 << LC_ALL, __s, __old); if (!__cloc) { // This named locale is not supported by the underlying OS. __throw_runtime_error(__N("locale::facet::_S_create_c_locale " "name not valid")); } } So the problem must be with your glibc setup. Is en_US.utf8 listed in /etc/locale.gen? Any other locales? Uncomment the ones you want to support, then try running /usr/sbin/locale-gen as root (I don't know if that's the right way to generate locale data for Ubuntu, you might want to ask on an Ubuntu forum) I've just tried it on a Debian box which only has en_US.utf8 locale data installed, and Axel's test program worked ok and running "./a.out en_US.utf8" wrote to the file unicode.txt, so the problem is not with the code or gcc.