[CentOS] How to Solve gcc version conflicts?

Source: Internet
Author: User

Today, I encountered a problem that is quite difficult. On centos, I used yum to install the compiling environment and run:

Yum-y install make gcc-c ++ kernel-devel m4 ncurses-devel openssl-devel

As a result, the compilation cocos2d-x has an error:

cc1plus: error: unrecognized command line option "-std=c++11"

I Googled and confirmed that this error was caused by a low gcc version.

View the gcc version:

Gcc -- version

System display:

Gcc (GCC) 4.8.2

I googled again and confirmed that this version supports c ++ 11.

But the compilation error for the cocos2d-x does occur after the yum command is run.

I searched gcc globally:

Find/-name gcc

There are so many gcc:

/Usr/lib/gcc
/Usr/local/lib/gcc
/Usr/local/bin/gcc
/Usr/local/libexec/gcc
/Usr/bin/gcc


Run again:

/Usr/bin/gcc -- version

Gcc (GCC) 4.4.7-4


/Usr/local/bin/gcc -- version

Gcc (GCC) 4.8.2


It seems that there are indeed two gcc instances on this machine. The shell runs/usr/local/bin/gcc, but cocos2dx make uses/usr/bin/gcc (why is the path inconsistent? The reason is unclear)

The solution is run;

Mv/usr/bin/gcc/usr/bin/gcc4.4.7

Ln-s/usr/local/bin/gcc/usr/bin/gcc


In addition, the commands g ++, cc, and c ++ should also be modified.

Mv/usr/bin/g ++ 4.4.7

Ln-s/usr/local/bin/g ++/usr/bin/g ++


Mv/usr/bin/cc/usr/bin/cc4.4.7

Ln-s/usr/local/bin/cc/usr/bin/cc


Mv/usr/bin/c ++ 4.4.7

Ln-s/usr/local/bin/c ++/usr/bin/c ++




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.