mar*_*tin 2 centos bash python gcc
我这样做是为了将 gcc 从 4.8.5 升级到 gcc 7:
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
source /opt/rh/devtoolset-7/enable
Run Code Online (Sandbox Code Playgroud)
这确实给了我当前 bash 终端中的 gcc 7。但是,如果我启动 python 终端,它显示 gcc 仍然是 gcc 4.8.5,如下所示:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)
Run Code Online (Sandbox Code Playgroud)
在 python 终端中:
$ python
Python 3.7.4 (default, Feb 24 2020, 16:34:54)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Run Code Online (Sandbox Code Playgroud)
另外,当我注销并重新登录到机器后,默认的 gcc 版本仍然是 4.8.5,我必须再次执行:
source /opt/rh/devtoolset-7/enable
Run Code Online (Sandbox Code Playgroud)
所以我有两个问题:
小智 11
我已经确认您可以在 centOS 7 上从默认版本 4.8 升级 gcc。
首先,我们需要安装“Software Collections”以便访问一些社区软件包,包括gcc v7
sudo yum install -y centos-release-scl
接下来,我们要安装开发人员工具集。根据您的需求,您可能需要不同的开发工具集。这里我的目标是 7:
sudo yum install -y devtoolset-7
最后,您需要更改为gcc 7
默认值,使用该工具启动新的 shell 会话scl
:
scl enable devtoolset-7 bash
归档时间: |
|
查看次数: |
16262 次 |
最近记录: |