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 ++