Weird characters in g++ compile errors â

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.


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.


3 thoughts on “Weird characters in g++ compile errors â

  1. 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 🙂


  2. 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.

  3. 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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s