You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Fedora 27环境下安装版本<6的gcc与g++求助

Hey there, I’ve been in your exact situation before—dealing with compiler version conflicts when building TensorFlow GPU can be a real headache. Let’s walk through how to install and switch to an older gcc/g++ version (below 6, we’ll use gcc 5 as an example) on your Fedora 27 system:

1. Install the older gcc/g++ packages

Fedora’s repositories still host older compiler versions, so we can grab them directly with dnf:

  • Run this command to install gcc 5 and g++ 5:
    sudo dnf install gcc5 gcc-c++5
  • Verify the installation worked by checking the versions:
    gcc5 --version
    g++5 --version
2. Manage multiple compiler versions with update-alternatives

Instead of overwriting your system’s default gcc 7 (which might break other tools), we’ll use update-alternatives to switch between versions safely:

  • Add gcc 5 and gcc 7 as alternative options:
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc5 10
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc7 20
  • Do the same for g++:
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++5 10
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++7 20
  • Switch to gcc 5 as the default:
    sudo update-alternatives --config gcc
    You’ll see a list of options—enter the number corresponding to /usr/bin/gcc5 and hit enter.
  • Repeat for g++:
    sudo update-alternatives --config g++
3. Confirm the switch worked

Run these commands to make sure your default compiler is now the older version:
gcc --version
g++ --version
You should see output showing gcc 5.x instead of 7.3.1.

Extra tips for TensorFlow compilation
  • If you need to switch back to gcc 7 later, just re-run the update-alternatives --config commands and select the gcc7 option.
  • To make sure TensorFlow uses the correct compiler during build, set these environment variables before starting the compilation process:
    export CC=/usr/bin/gcc5
    export CXX=/usr/bin/g++5

内容的提问来源于stack exchange,提问作者DEVENDRA MEENA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:24:51