简体   繁体   English

gcc和g ++错误:尝试执行'cc1plus'时出错:execvp:没有这样的文件或目录

[英]gcc and g++ error: error trying to exec 'cc1plus': execvp: No such file or directory

I'm having problems compiling .c and .cpp files using gcc and g++ , for both cases i got the message: 我在使用gccg++编译.c.cpp文件时遇到问题,对于这两种情况我收到了消息:

g++(or gcc): error trying to exec 'cc1plus': execvp: No such file or directory`

I've already tried to reinstall both gcc and g++ and be sure that they're both in the same version. 我已经尝试重新安装gcc和g++并确保它们都在同一个版本中。

Edits: I'm using ubuntu 16.04.1 LTS, both g++ and gcc are in version 5.4.0 20160609. 编辑:我使用的是ubuntu 16.04.1 LTS,g ++和gcc都在版本5.4.0 20160609中。

The following is the output of echo | g++ -v -xc++ -fsyntax-only - 以下是echo | g++ -v -xc++ -fsyntax-only -的输出 echo | g++ -v -xc++ -fsyntax-only - : echo | g++ -v -xc++ -fsyntax-only -

Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --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 --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 
COLLECT_GCC_OPTIONS='-v' '-fsyntax-only' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 cc1plus -quiet -v -imultiarch x86_64-linux-gnu -iprefix ../lib/gcc/x86_64-linux-gnu/5/ -D_GNU_SOURCE - -quiet -dumpbase - -mtune=generic -march=x86-64 -auxbase - -version -fsyntax-only -o /dev/null -fstack-protector-strong -Wformat -Wformat-security
g++: error trying to exec 'cc1plus': execvp: No such file or directory

Thats the outuput of compiling a hello world program with gcc -v: 这是用gcc -v编译hello world程序的输出:

Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --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 --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 cc1 -quiet -v -imultiarch x86_64-linux-gnu -iprefix ../lib/gcc/x86_64-linux-gnu/5/ codigo.c -quiet -dumpbase codigo.c -mtune=generic -march=x86-64 -auxbase codigo -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/cckVKe9E.s
gcc: error trying to exec 'cc1': execvp: No such file or directory

The following is the output of /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus </dev/null : 以下是/usr/lib/gcc/x86_64-linux-gnu/5/cc1plus </dev/null

Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <free-inline-summary> <whole-program> <inline>Assembling functions:

Execution times (seconds)
 phase setup             :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 (20%) wall    1408 kB (81%) ggc
 phase parsing           :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 (20%) wall     318 kB (18%) ggc
 parser (global)         :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 (20%) wall     302 kB (17%) ggc
 TOTAL                 :   0.00             0.00             0.05               1746 kB

Something has been broken in your GCC installation (read also about GCC environment variables & spec files ). 您的GCC安装中已经破坏了某些内容(另请参阅GCC 环境变量规范文件 )。

Check also your environment, be sure to avoid any GCC_EXEC_PREFIX environment variables 检查您的环境,确保避免任何GCC_EXEC_PREFIX环境变量

I would suggest to re-install with aptitude : 我建议用aptitude重新安装:

aptitude reinstall gcc-5 g++-5

(perhaps you need to replace both occurrences of 5 by 6 , at least on newer versions of Ubuntu) (也许你需要替换56出现次数,至少在较新版本的Ubuntu上)

Then compile some hello world program with gcc -v to be sure it is working. 然后使用gcc -v编译一些hello world程序,以确保它正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编译错误:“g++:尝试执行&#39;cc1plus&#39;时出错:execvp:没有这样的文件或目录” - Compile error: “g++: error trying to exec 'cc1plus': execvp: No such file or directory” Trilinos - c ++:试图执行&#39;cc1plus&#39;时出错:execvp:没有这样的文件或目录 - Trilinos - c++: error trying to exec 'cc1plus': execvp: No such file or directory PHP exec()使用cc1plus导致g ++错误 - PHP exec() causes g++ error with cc1plus 尝试执行&#39;cc1&#39;的gcc错误:execvp:与非root用户一起运行时没有这样的文件或目录 - gcc error trying to exec 'cc1': execvp: No such file or directory when running with non-root user cc1plus:错误:无法识别的命令行选项“ -fsysroot = <path> ”和g ++ - cc1plus: error: unrecognized command line option “-fsysroot=<path>” with g++ g++:内部编译器错误:分段错误(程序 cc1plus)- 我从哪里开始? - g++: internal compiler error: Segmentation fault (program cc1plus) - where do I start? cc1plus:错误:使用g ++无法识别的命令行选项“-std = c ++ 11” - cc1plus: error: unrecognized command line option “-std=c++11” with g++ GCC 5.2 cc1、cc1plus 错误 - GCC 5.2 Error with cc1, cc1plus 在 Linux 上的 C++ 源文件上运行“gcc”会给出“cc1plus:内存分配不足……”错误消息 - Running 'gcc' on C++ source file on Linux gives “cc1plus: out of memory allocating …” error message 尝试使用 MinGW 编译时出错:无法执行 cc1plus - error when trying to compile with MinGW: cannot execute cc1plus
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM