From sashi at gmx.de Sun Apr 20 12:05:23 2008 From: sashi at gmx.de (sashi) Date: Sun Apr 20 12:05:30 2008 Subject: Localization (L10n) with libstdc++ aborts with an exception Message-ID: <480B2BEE.4010701@gmx.de> Hello, while trying to instantiate std::locale on my FreeBSD 7.0-R system with LANG=de_DE.UTF-8, the compiled code aborts with an exception. Only LANG=C works. Here's the code you may want to try (compile with CC ): #include #include #include int main() { using std::cout; using std::endl; // C L10n const char* const lstr = std::setlocale(LC_ALL, ""); cout << "C setlocale()\nresult="; cout << ( lstr ? lstr : "0" ) << "\n" << endl; // C++ L10n cout << "C++ std::locale" << endl; std::locale loc(""); cout << "std::locale loc=" << loc.name() << endl; } Output (run with ./a.out): C setlocale() result=de_DE.UTF-8 C++ std::locale terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid Abort (core dumped) My $LANG is set to de_DE.UTF-8 (via login.conf). locale -a|grep de_DE reports: de_DE.ISO8859-1 de_DE.ISO8859-15 de_DE.UTF-8 What I've found out so far: I suppose it has something to do with how libstdc++ is build under fBSD. There is an option for libstdc++ called --enable-clocale[=MODEL] use MODEL for target locale package [default=auto] the MODELs are located in the base system source directory /usr/src/contrib/libstdc++/config/locale/ And probably the "generic" (or "darwin") model is used, instead of "gnu" ?! Can anyone please help me with this ? gcc -v reports: Using built-in specs. Target: i386-undermydesk-freebsd Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 4.2.1 20070719 [FreeBSD] on my FreeBSD 7.0-RELEASE system. Thanks in advance for any ideas. -- Sashi Asokarajan