I have a problem whenever I try to compile any C program. Being it the simplest hello world:
#include <stdio.h>
int main() {
printf("HelloWorld");
}
If I try to compile I get the following error:
gcc: error trying to exec 'cc1': execvp: No such file or directory
I read online, and here on stackoverflow as well, that in this case gcc
isn't properly installed and we have to reinstall it (or reinstall build-essential, depending on the distribution).
However, I can't follow this path. If I look for cc1 I can find it on my system:
$ locate cc1
/lib/modules/4.15.0-54-generic/kernel/drivers/iio/adc/cc10001_adc.ko
/usr/lib/gcc/x86_64-linux-gnu/7/cc1
/usr/lib/gcc/x86_64-linux-gnu/7/cc1plus
/usr/lib/gcc/x86_64-linux-gnu/7/libcc1.so
/usr/lib/gcc/x86_64-linux-gnu/7/plugin/libcc1plugin.so
/usr/lib/gcc/x86_64-linux-gnu/7/plugin/libcc1plugin.so.0
/usr/lib/gcc/x86_64-linux-gnu/7/plugin/libcc1plugin.so.0.0.0
/usr/lib/x86_64-linux-gnu/libcc1.so.0
/usr/lib/x86_64-linux-gnu/libcc1.so.0.0.0
/usr/share/doc/libcc1-0
/usr/share/doc/libgcc1
/usr/share/doc/libisccc160
/usr/share/doc/libisccc160/changelog.Debian.gz
/usr/share/doc/libisccc160/copyright
/usr/share/lintian/overrides/libgcc1
----AND MORE----
gcc
is symlinked to gcc-7
:
$ ls -l | grep gcc
-rwxr-xr-x 1 root root 428 May 7 2006 c89-gcc
-rwxr-xr-x 1 root root 454 Apr 11 2011 c99-gcc
lrwxrwxrwx 1 root root 5 May 20 19:08 gcc -> gcc-7
lrwxrwxrwx 1 root root 22 May 8 18:53 gcc-7 -> x86_64-linux-gnu-gcc-7
lrwxrwxrwx 1 root root 8 May 20 19:08 gcc-ar -> gcc-ar-7
----AND MORE----
My gcc
version is 7.4.0:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
And in /usr/lib/gcc/x86_64-linux-gnu
I can see that my version folder is symlinked to the 7 folder:
/usr/lib/gcc/x86_64-linux-gnu$ ls -l
total 8
drwxr-xr-x 5 root root 4096 Jul 2 14:38 7
lrwxrwxrwx 1 root root 1 May 8 18:53 7.4.0 -> 7
How can I tell gcc
where is cc1
? Is it possible to do it? What's wrong here?
Again, I can't reinstall gcc or any other package. I want to know if this can be solved without doing it. If it's impossible, I have to find another way of doing what I need to do.
/usr/lib/gcc/x86_64-linux-gnu/7/
toPATH
. Also you could try runninggcc-7
andx86_64-linux-gnu-gcc-7
instead of plaingcc
./usr/lib/x86_64-linux-gnu/7/
, that is without/gcc
in the middle.-B
to tell it where to find things. (Obviously you don't want to do that every day, but sometimes it's a way to get started.)gcc-7
already but nothing. Added that path toPATH
and still nothing. Thanks anyway. :)cc1
with-B
it found it. And then it wasn't findingld
, so I had to add another-B /usr/bin
. Incredible how broken wasgcc
installation on this machine. :D If you'll post it as an answer, I'll accept it. Thank you very much!