39

I'm a newbie but adventuresome. I'm tri-booting Windows, Fedora, and Ubuntu 14.04 LTS (all 64). Learning but not using dpkg, apt, and apt-get. Starting to study C++ using Ubuntu (the only one with gcc installed). So on my first attempted compile I ran the command gcc xy.cc and got the following:

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

So I searched my computer for cc1plus and execvp. And found neither. Just execvp.3.gz in directory /user/share/man/man3 and cc1 in /user/lib/gcc/x86_64-linux-gnu/4.8.

So a whole bunch of work and learning about the package getters and checkers, but no courage to remove and reinstall etc.

Do you have some suggestions?

2 Answers 2

55

You're possibly missing g++ package on your machine. Open a terminal and install it using the below command:

sudo apt-get install g++

To compile using g++ use this

g++ -o test.o test.cpp

g++ can be used to compile C++ source, the default ubuntu installation comes with gcc, but not with g++.

You are trying to compile C++ source using a C compiler. gcc usually successfully compiles C++ code but by default it doesn't link any c++ specific libraries (refer to this answer on Stack Overflow).

If a message displays like : Couldn't find package ..., then try the following commands

sudo apt-get update && sudo apt-get upgrade

then

sudo apt-get install g++
1
  • I had g++ but it was g++-9, my build was using GCC-11, so I installed g++-11 to fix it.
    – mndrix
    Jan 10, 2022 at 21:44
14

cc1plus is the c++ backend (real compiler) for gcc, if you are primarily going to program in c++ you will really want to install g++ (will have cc1plus with it). Using one the package system front ends apt-get, synaptic, software manager, or a number of others it will install the dependencies with it.

execvp is a programming function, the file you found matching it is the man (manual) page for it. to view it open a terminal and type man execvp. The man pages are often times online, and they have a TON of info in them on cli and programming stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.