先获取 root 权限 yum install centos-release-scl-rh centos-release-scl yum check-update yum install devtoolset-4-gcc devtoolset-4-gcc-c++ 安装完毕后, 需要手动开启(如果需要自动开启, 需要加到 bashrc 中) source /opt/rh/devtoolset-4/enable 其中的devtoolset版本写4 5 6 7都行,对应到不同版本的gcc