-
错误提示“E: Couldn’t find any package by regex ‘gcc-c+’”
- 原因:Debian 的包名是 g++,不是 gcc-c++。
- 解决:执行 sudo apt install g++ 或 sudo apt install build-essential。
-
依赖冲突或“g++ : Depends: g+±X (>= …) but it is not going to be installed”
- 解决:安装 aptitude 并让其自动求解依赖:
- sudo apt install aptitude
- sudo aptitude install g++
- 在交互提示中,若首方案不合理,先选 n 拒绝,等待更优方案再选 y 接受。
-
“configure: error: C compiler cannot create executables”或“no acceptable C compiler found in $PATH”
- 原因:没有可用的 C 编译器 或 PATH 配置异常。
- 解决:先安装编译器(如 sudo apt install build-essential),再确认 which gcc 与 echo $PATH 包含 /usr/bin。
-
构建 GCC 源码时报错“configure: error: Building GCC requires GMP 4.2+”
- 解决:安装编译依赖:sudo apt install libgmp-dev libmpfr-dev libmpc-dev。
-
网络或镜像源导致下载失败、速度慢或 403
- 解决:更换为国内镜像源(如清华源),然后 sudo apt update。示例(Debian 11/12 常见写法):
- 编辑 /etc/apt/sources.list,将官方域名替换为 https://mirrors.tuna.tsinghua.edu.cn,保存后执行 sudo apt update。