2

I'm trying to compile a simple .cu file with CUDA 5 and gcc 4.7.3 on Ubuntu 13.0 but I'm getting

gcc: error trying to exec 'cc1plus': execvp: No such file or directory

How can I fix this?

talonmies
  • 70,661
  • 34
  • 192
  • 269
Marco A.
  • 43,032
  • 26
  • 132
  • 246

2 Answers2

3

You do not have a valid C++ compiler installed. Install g++ and the problem will go away - nvcc requires a working, supported C++ host compiler to compile both device and host code.

Community
  • 1
  • 1
talonmies
  • 70,661
  • 34
  • 192
  • 269
3

I also had this problem. And I checked my g++ it works well. Finally I found the problem and solved it, I hope I can help those who have the same problem.

If you do not has g++ installed, try install it.

If you had a valid g++ and problem still exists, try two command respectively

gcc --version
g++ --version

If the output gcc version is different, that is the problem.

In my case the version of gcc is 7.4, g++ is 5.5. I want to use 7.4 so I run those command:

cd /usr/bin/
sudo rm gcc
sudo rm g++
sudo ln -s gcc-7 gcc
sudo ln -s g++-7 g++

And the problem disappeared.

If you want to use other versions, just change '7' to the version you want (may be '5').

Instein
  • 2,484
  • 1
  • 9
  • 14
  • 1
    You can use `sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8` `sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8` for example to fix this – James Jan 14 '20 at 15:14