5

I'm having problems compiling .c and .cpp files using gcc and g++, for both cases i got the message:

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.

Edits: I'm using ubuntu 16.04.1 LTS, both g++ and gcc are in version 5.4.0 20160609.

The following is the output of 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:

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:

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
Felipe Chabatura
  • 61
  • 1
  • 1
  • 6
  • 3
    This question requires code and build commands. – Dellowar Jan 09 '17 at 18:52
  • i can't compile any code, not even a Hello World, about the build commands i just type "g++ " for example. – Felipe Chabatura Jan 09 '17 at 18:55
  • 2
    What OS are you on? – Dellowar Jan 09 '17 at 18:56
  • What version of GCC? From the error message it looks like you're doing this on Windows - is this MinGW or Cygwin (and specify which version). Older versions of MinGW sometimes had trouble with finding executables, but I forget the details. If you're using something pretty old, you might want to try updating. – Michael Burr Jan 09 '17 at 18:57
  • Check that there are no stray executables in your PATH named g++.exe or the like. Try invoking g++ with a full path. – n. m. could be an AI Jan 09 '17 at 19:00
  • Please run the command `echo | g++ -v -xc++ -fsyntax-only -`, and then edit your question (click on the small gray word "edit" under the tags), copy and paste the *complete, unedited* output of that command into the edit box and save. – zwol Jan 09 '17 at 19:13
  • Several questions about this error message have been posed before; many of them are linked in the sidebar. Please check whether any of those apply to your case. If not, please add the information necessary to distinguish yours. – John Bollinger Jan 09 '17 at 19:28
  • @MichaelBurr, what about that error message makes you think "Windows"? I'm inclined to think *non*-Windows, but with MinGW and Cygwin in the mix, that's not really black & white. Certainly, however, exactly the error message reported here has been observed on Linux in the past. – John Bollinger Jan 09 '17 at 19:32
  • 4
    This does seem suspiciously like an incorrectly installed GCC. I wonder what `find /usr/lib -name cc1plus 2>/dev/null` would yield. – Dietrich Epp Jan 09 '17 at 20:22
  • Also note that the same error message can be caused by a missing shared library. – Dietrich Epp Jan 09 '17 at 20:23
  • `find /usr/lib -name cc1plus 2>/dev/null` returned: /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus , i've installed both gcc and g++ through ubuntu repositories, via terminal. – Felipe Chabatura Jan 09 '17 at 20:26
  • @JohnBollinger: my mistake - I thought the error message for this kind of thing was worded differently on Linux. – Michael Burr Jan 09 '17 at 20:31
  • 1
    Another test command: `echo | strace -f -eexecve g++ -xc++ -fsyntax-only -` – zwol Jan 09 '17 at 20:40
  • 1
    This isn't an _answer_, but just to explain a little what the problem is: The program installed as `g++` in a public "bin" directory is a wrapper. All the actual work of compilation is done by another program, `cc1plus`, which is installed in a private directory (in your case, `/usr/lib/gcc/x86_64-linux-gnu/5/`). The error message you're getting indicates that the wrapper is failing to run the internal program. We still don't know _why_. – zwol Jan 09 '17 at 20:42
  • `echo | strace -f -eexecve g++ -xc++ -fsyntax-only -` returns: strace: Can't stat 'g++': No such file or directory – Felipe Chabatura Jan 09 '17 at 21:11
  • Could it be caused by an issue with 2 different versions being installed on the system? OP seems to have both gcc 4.8 and gcc 5 installed. – Chimera Jan 09 '17 at 21:37
  • The commands `g++ --version` and `gcc --version` returned the exact same version, 5.4.0 20160609. – Felipe Chabatura Jan 09 '17 at 21:39
  • The output of `find /usr/lib -name cc1plus 2>/dev/null` indicates more than one version is installed. – Chimera Jan 09 '17 at 21:44
  • 1
    @Chimera: That's usually not anything to be worried about. – Dietrich Epp Jan 09 '17 at 21:47
  • Try `sudo apt-get install --reinstall gcc-5.4` – Chimera Jan 09 '17 at 21:48
  • 1
    Try running `/usr/lib/gcc/x86_64-linux-gnu/5/cc1plus – Dietrich Epp Jan 09 '17 at 21:49
  • Try running `make julianne_fries` – Chimera Jan 09 '17 at 21:56
  • @Chimera: there is no package named gcc-5.4 – Felipe Chabatura Jan 09 '17 at 22:07
  • 2
    Please, check out the answers in here [http://stackoverflow.com/questions/11912878/gcc-error-gcc-error-trying-to-exec-cc1-execvp-no-such-file-or-directory](http://stackoverflow.com/questions/11912878/gcc-error-gcc-error-trying-to-exec-cc1-execvp-no-such-file-or-directory) and see if some of the suggestion there, which also have been provided here, work for you. Change occurrences of `cc1` from the other link to `cc1plus`, which is your case. – fedepad Jan 09 '17 at 22:31
  • 2
    I'm sorry, I should have said `echo | strace -f -eexecve $(which g++) -xc++ -fsyntax-only -`. – zwol Jan 09 '17 at 22:42
  • What happens when you run /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus directly? – n. m. could be an AI Jan 10 '17 at 21:00
  • Also post output of `which g++` and `printenv`. – n. m. could be an AI Jan 10 '17 at 21:04
  • 1
    the cc1 program should be located at: `/usr/lib/gcc/x86_64-linux-gnu/5/cc1` – user3629249 Jan 11 '17 at 02:35
  • Thank you for all the support, i eventually had to reinstall ubuntu , what solved the problem – Felipe Chabatura Jan 14 '17 at 21:22

1 Answers1

2

Something has been broken in your GCC installation (read also about GCC environment variables & spec files).

Check also your environment, be sure to avoid any GCC_EXEC_PREFIX environment variables

I would suggest to re-install with 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)

Then compile some hello world program with gcc -v to be sure it is working.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • 3
    Since apparently there is no packages "gcc-6" and "g++-6" i tried with "gcc-5" and "gcc-5" , it finishes the installation but it did not solve the problem. – Felipe Chabatura Jan 09 '17 at 21:43