i recently installed Ubuntu on a VMware and following a tutorial... gcc works for me, but when i try g++, it says " The program 'g++' is currently not installed. You can install it by typing: sudo apt-get install g++ " but, when i do and return to compile a c++ file. It still says the same thing.
EDIT
- I tried reinstalling it, didn't work. It doesn't give any error messages per say, but it opens a list of packages that are "the newest version" and when i search for g++ among them, it isn't there.
- I tried to locate where it exists, with command " ls -l /usr/bin g++ " i get, " no such file or directory. "
- output of command " lsb_release -a " No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Relase: 14.04 Codename: trusty.
- output of command "uname -a" Linus ubuntu 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 20 15 x86_64 GNU/Linux.
- I get nothing by typing " command -v g++ ".
- And I dont see g++'s description like the others i see when i use "apt-cache policy g++".
4 Answers
What solved this problem for me was simply uninstalling then reinstalling in 2 steps:
sudo apt-get remove g++
sudo apt-get install g++ 1 I had this same problem after installing CUDA. It turns out g++ was there but was a broken symbolic link. You can check if this is your case by doing:
ls /usr/bin | grep g++and if it exists, its probably a broken link, so just do sudo rm /usr/bin/g++ and then create a new symlink:
sudo ln -s g++-7 /usr/bin/g++(This assumes g++-7 exists, or some other version of it)
You have done the right thing to install g++, so we need to investigate why it still isn't working. Here are some things to try:
- Try installing it again:
sudo apt-get install g++. You should get the messageg++ is already the newest version. If not, what message do you get? Do you get any error messages? Find out what is where
g++should live. Typels -l /usr/bin/g++. You should find a simlink to the actual binary:lrwxrwxrwx 1 root root 7 Apr 7 2014 /usr/bin/g++ -> g++-4.8Sometimes things can go wrong here if
/usr/bin/g++points to somewhere in/etc/alternatives, but the/etc/alternativeslink points to the wrong place.Ask back here. When you ask back here, including the output of commands such as
lsb_release -a,uname -a,command -v g++, andapt-cache policy g++would be very helpful, as recommended by @A.B. In fact, if you ask back here, it's best to do so by editing your question above rather than by asking a new question.
If you already have multiple versions of g++ they will be called with the version number on the end. See the output of:
ls /usr/bin/g++*
I have:
/usr/bin/g++-5 /usr/bin/g++-7
Instead of calling g++ I need to call g++-5 or g++-7