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