如何在CentOS上使用高版本的GCC编译

2025-05-23 20:26:00
推荐回答(1个)
回答1:

为了不影响本机的gcc环境,开发工具默认安装在‘/opt/centos/devtoolset-1.1/root/’目录下。需要修改用户的环境变量方可使用:

export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc  
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp 
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++

推荐使用gcc默认给出的环境变量设置脚本‘/opt/centos/devtoolset-1.1/enable ’。将其加到有需要用户的环境变量中,重新登录即生效。

echo 'source /opt/centos/devtoolset-1.1/enable' >> ~/.bash_profile