On 28 June 2011 08:13, eric <fsshl@xxxxxxx> wrote: > On Tue, 2011-06-28 at 01:16 +0100, Jonathan Wakely wrote: >> On 28 June 2011 01:14, eric wrote: >> > On Tue, 2011-06-28 at 00:57 +0100, Jonathan Wakely wrote: >> >> 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 > > And I do this step, after I copy that link's sample locale.gen on my > /etc/ directory. > >> >> (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. >> > ---------------------------- >> > my system don't have /etc/locale.gen >> > but >> > it have /etc/locale.alias >> >> That isn't the same. >> >> You'll need to find someone who knows how to install localization data >> files on Ubuntu. >> >> This isn't a gcc issue. > ------------------------------------------------------------ > I follow the link and its suggestion(hardway) > -- > http://people.debian.org/~schultmc/locales.html > > -------------- > > A sample /etc/locale.gen > # This file lists locales that you wish to have built. You can find a list > # of valid supported locales at /usr/share/i18n/SUPPORTED. Other > # combinations are possible, but may not be well tested. If you change > # this file, you need to rerun locale-gen. > # > # XXX GENERATED XXX > # > # NOTE!!! If you change this file by hand, and want to continue > # maintaining manually, remove the above line. Otherwise, use the command > # "dpkg-reconfigure locales" to manipulate this file. You can manually > # change this file without affecting the use of debconf, however, since it > # does read in your changes. > > en_US.UTF-8 UTF-8 > ---------------------------------------------------------------- > then run again test code Did you run locale-gen? > Not work > same error, by out << sw2 << endl; > out.good() is 0 > and when I use no argument, just ./a.out, error > can not generate locale > > looking to see any experienced c/g++ and ubuntu/linux programer's help > thanks a lot in advance > Eric > > >