我有一个比较老的服务器,上面有CentOS 6。默认的gcc是4.4.7,但是在googling之后,我发现我可以通过devtoolset-7更新这个。我通过root安装了devtoolset-7 (即sudo -i),它安装得很好。
然后我做了scl enable devtoolkit-7 bash,但它似乎什么也没做。
[affan@abm-lab ~]$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[affan@abm-lab ~]$ scl enable devtoolset-7 bash
[affan@abm-lab ~]$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.有人知道为什么scl不启用一个具有适当变量集的子环境吗?
发布于 2020-02-26 15:38:00
我也有这个问题。我不知道为什么scl无法启用环境,但我能够用source /opt/rh/devtoolset-7/enable加载它。
发布于 2020-09-30 19:09:16
这是因为您在.bashrc和/或.bash_profile中的设置。在启动新bash之前,scl将其路径附加到gcc7,但gcc的路径再次默认为旧gcc4,因为在启动新bash时,.bashrc会将/usr/bin追加到路径中,并取代scl设置。解决方案是直接使用“启用”脚本。这样就不会有更多的路径设置让你烦恼。
https://serverfault.com/questions/1002266
复制相似问题