CentOS gcc编译报错:gcc: error trying to exec ‘cc1plus‘: execvp: No such file or directory(原因:g++没安装)
Posted Dontla
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS gcc编译报错:gcc: error trying to exec ‘cc1plus‘: execvp: No such file or directory(原因:g++没安装)相关的知识,希望对你有一定的参考价值。
如下报错:
[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]#
然后我把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]#
然后我再重装gcc和g++(其实貌似也可以不用卸载gcc,直接安装g++就可以了)
yum install gcc
yum install gcc-c++
然后查看gcc和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]#
然后我再执行编译,通过了
参考文章:centOS系统安装g++
以上是关于CentOS gcc编译报错:gcc: error trying to exec ‘cc1plus‘: execvp: No such file or directory(原因:g++没安装)的主要内容,如果未能解决你的问题,请参考以下文章
centos6 编译的程序需要在 centos7上运行报错 error while loading shared libraries: libgtop-2.0.so.7?
gcc源码编译报错:error: dereferencing pointer to incomplete type ‘struct ucontext’ 解决办法
Linux centos6.5系统下升级gcc4.8.2时,编译gcc时出现错误,请求帮助
Linux下gcc编译报错:fatal error: linux/cyclades.h: No such file or directory 解决办法