Gcc error: gcc: error trying to exec 'cc1': execvp: No such file or directory

gcc
Scooter picture Scooter · Aug 11, 2012 · Viewed 255.5k times · Source

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

Answer

maxkoryukov picture maxkoryukov · Jun 22, 2017

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)

What is cc1:

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.

taken from this answer by Alan Shutko.

Solution for: Ubuntu / Linux Mint

sudo apt-get update
sudo apt-get install --reinstall build-essential

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

Better package name provided by Pablo Castellano. More details here.

If you need more packages for building purposes, consider adding of the alpine-sdk package:

RUN apk add alpine-sdk

Taken from github

Solution for: CentOS/Fedora

This answer contains instructions for CentOS and Fedora Linux

Solution for: Amazon Linux

sudo yum install gcc72-c++

Taken from this comment by 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

Taken from this answer