If the locale of your environment isn’t compatible with the terminal you are using, g++ will spit out weird characters. To check your current locale in Linux, use the command “locale” from the command prompt. en_US.UTF-8 encoding was giving me the weird characters in a 32-bit CentOS distro running on a vmware machine.
Solution:
Enter the commands: “export LC_ALL=C” and “export LANG=C”
After changing the locales, the characters in my g++ error messages disappeared but only for my current terminal session. To change it permanently, I had to change the default locale setting.
Change the default locale in CentOS:
edit the file: /etc/sysconfig/i18n
edit the first line to be: LANG=”C”
All other terminal sessions should use the POSIX/C locale as the default now.
Hey Thanks!
I had this problems since months and had no clue how to fix it. Till I decided to Google with lots of different terms and came up to your page 🙂
cheers,
Janak
Nice! I also have had this problem for a long time while using newer g++. Thanks so much for posting this.
FYI: I already had the right ‘LANG’ setting but needed the ‘LC_ALL’ setting.
Thanks a ton, it worked right away and I can get back to coding now. I was getting this while SSHing into my university’s computers. I would think that they would have figured out that this is a problem and provided some sort of fix, given that everyone in the CS department has to make sure that their code compiles using g++ before using it on any of the systems.
yet again thanks, you’re a life saver