Gcc 错误:gcc:尝试执行 'cc1' 时出错:execvp:没有这样的文件或目录 [英] Gcc error: gcc: error trying to exec 'cc1': execvp: No such file or directory
问题描述
我已在 Linux Mint 12 上成功使用 gcc.现在出现错误.我最近一直在做一些 .so 构建和安装 Clang 不久前,但自从这两个事件以来已经成功编译,所以不确定发生了什么变化.我用GUI软件管理器把gcc删除然后重新安装,结果还是一样:
I have been successfully using gcc on Linux Mint 12. Now I am getting an error. I have recently been doing some .so builds and installed Clang not to long ago, but have successfully compiled since both of those events, so not sure what has changed. I used the GUI Software Manager to remove and then install gcc again, but the results are the same:
~/code/c/ut: which gcc
/usr/bin/gcc
~/code/c/ut: gcc -std=c99 -Wall -Wextra -g -c object.c
gcc: error trying to exec 'cc1': execvp: No such file or directory
推荐答案
说明
错误消息告诉我们,未找到构建时依赖项(在本例中为 cc1
),因此我们只需要 - 将适当的包安装到系统中(使用包管理器//从来源//另一种方式)
Explanation
The error message told us, that the build-time dependency (in this case it is cc1
) was not found, so all we need — install the appropriate package to the system (using package manager // from sources // another way)
什么是cc1
:
cc1
是内部命令,它接受预处理的 C 语言文件并将它们转换为汇编.它是编译 C 的实际部分.对于 C++,有 cc1plus 和其他不同语言的内部命令.
cc1
is the internal command which takes preprocessed C-language files and converts them to assembly. It's the actual part that compiles C. For C++, there's cc1plus, and other internal commands for different languages.
sudo apt-get update
sudo apt-get install --reinstall build-essential
解决方案:Docker-alpine 环境
如果您在 docker-alpine 环境中,请安装 build-base 包,将其添加到您的 Dockerfile
中:
Solution for: Docker-alpine environment
If you are in docker-alpine environment install the build-base package by adding this to your Dockerfile
:
RUN apk add build-base
Pablo Castellano 提供了更好的包名称.更多详情请点击此处.
Better package name provided by Pablo Castellano. More details here.
如果您需要更多软件包用于构建目的,请考虑添加 alpine-sdk 包:
If you need more packages for building purposes, consider adding of the alpine-sdk package:
RUN apk add alpine-sdk
取自 github
这个答案包含 CentOS 和 Fedora Linux 的说明
This answer contains instructions for CentOS and Fedora Linux
sudo yum install gcc72-c++
取自 此评论 来自 CoderChris
您也可以尝试通过此安装丢失的依赖项(虽然,据说不能解决问题):
You could also try to install missed dependencies by this (though, it is said to not to solve the issue):
sudo yum install gcc-c++.noarch
摘自这个答案
这篇关于Gcc 错误:gcc:尝试执行 'cc1' 时出错:execvp:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!