CentOS:gcc: error trying to exec ‘cc1plus‘: execvp: No such file or directory...

created at 05-29-2022 views: 39

error

[root@localhost ky_volume]# gcc book250.cpp -o book250
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
[root@localhost ky_volume]# 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# gcc --verson
gcc: error: unrecognized command line option ‘--verson’
gcc: fatal error: no input files
compilation terminated.
[root@localhost ky_volume]# 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# g++ -v
bash: g++: command not found...
[root@localhost ky_volume]# 
[root@localhost ky_volume]# 

solution

I uninstalled gcc

yum remove gcc
[root@localhost ky_volume]# yum remove gcc
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-44.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch            Version                  Repository          Size
================================================================================
Removing:
 gcc          x86_64          4.8.5-44.el7             @anaconda           37 M

Transaction Summary
================================================================================
Remove  1 Package

Installed size: 37 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : gcc-4.8.5-44.el7.x86_64                                      1/1 
  Verifying  : gcc-4.8.5-44.el7.x86_64                                      1/1 

Removed:
  gcc.x86_64 0:4.8.5-44.el7                                                     

Complete!
[root@localhost ky_volume]# 

Then I reinstall gcc and g++ (in fact, it seems that you can install g++ directly without uninstalling gcc)

yum install gcc
yum install gcc-c++

Then check the version of gcc and g++

gcc -v
g++ -v
[root@localhost ky_volume]# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
[root@localhost ky_volume]# 
[root@localhost ky_volume]# 

Then I execute the compilation again, success!

created at:05-29-2022
edited at: 05-29-2022: