Compile error: “g++: error trying to exec 'cc1plus': execvp: No such file or directory”

后端 未结 9 1660
情深已故
情深已故 2020-12-04 20:52

When I compile C/C++ program with popen in php... I got this error:

g++: error trying to exec \'cc1plus\': execvp: No such file or          


        
相关标签:
9条回答
  • 2020-12-04 21:01

    I had the same issue when forking with 'python'; the main reason is that the search path is relative, if you don't call g++ as /usr/bin/g++, it will not be able to work out the canonical paths to call cc1plus.

    0 讨论(0)
  • 2020-12-04 21:04

    You need to install gcc-c++ package.

    yum install gcc-c++
    
    0 讨论(0)
  • 2020-12-04 21:04

    This problem can happen if different versions of g++ and gcc are installed.

       g++ --version
       gcc --version
    

    If these don't give the result, you probably have multiple versions of gcc installed. You can check by using:

        dpkg -l | grep gcc | awk '{print $2}'
    

    Usually, /usr/bin/gcc will be sym-linked to /etc/alternatives/gcc which is again sym-linked to say /usr/bin/gcc-4.6 or /usr/bin/gcc-4.8 (In case you have gcc-4.6, gcc-4.8 installed.)

    By changing this link you can make gcc and g++ run in the same version and this may resolve your issue!

    0 讨论(0)
  • 2020-12-04 21:09

    Install g++ on openSuSE run

    zypper in gcc-c++
    
    0 讨论(0)
  • 2020-12-04 21:12

    I don't know why but i just renamed my source file COLARR.C to colarr.c and the error vanished! probably you need this

    sudo apt-get install g++
    
    0 讨论(0)
  • 2020-12-04 21:15

    Each compiler has its own libexec/ directory. Normally libexec directory contains small helper programs called by other programs. In this case, gcc is looking for its own 'cc1' compiler. Your machine may contains different versions of gcc, and each version should have its own 'cc1'. Normally these compilers are located on:

    
    /usr/local/libexec/gcc/<architecture>/<compiler>/<compiler_version>/cc1
    

    Similar path for g++. Above error means, that the current gcc version used is not able to find its own 'cc1' compiler. This normally points to a PATH issue.

    0 讨论(0)
提交回复
热议问题