gpt4 book ai didi

c++ - gcc 和 g++ 错误 : error trying to exec 'cc1plus' : execvp: No such file or directory

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:07:55 27 4
gpt4 key购买 nike

我在编译时遇到问题 .c.cpp使用 gcc 的文件和 g++ ,对于这两种情况,我都收到了消息:

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

我已经尝试重新安装 gcc 和 g++并确保它们的版本相同。

编辑:我使用的是 ubuntu 16.04.1 LTS,g++ 和 gcc 的版本都是 5.4.0 20160609。

以下是 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

这就是用 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

以下是 /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

最佳答案

您的 GCC 中有些东西坏了安装(另请阅读 GCC environment variablesspec files )。

同时检查您的环境,确保避免使用任何GCC_EXEC_PREFIX 环境变量

我建议使用 aptitude 重新安装:

aptitude reinstall gcc-5 g++-5

(也许您需要将两次出现的 5 替换为 6,至少在较新版本的 Ubuntu 上是这样)

然后用 gcc -v 编译一些 hello world 程序以确保它能正常工作。

关于c++ - gcc 和 g++ 错误 : error trying to exec 'cc1plus' : execvp: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41554900/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com