0

I installed Ubuntu 20.04 and I installed g++ using

sudo apt install g++ 
sudo apt install build-essential

but when I want to check the version using this command

g++ --version

it showed me and also for gcc same the situation

Command 'g++' not found, but can be installed with:

sudo apt install g++

Is there any way to check whether the g++ installed or not?

you can see the photo

Kulfy
  • 17,416
  • 26
  • 64
  • 103
John
  • 1
  • 2
  • Run `sudo apt update` and then `sudo apt install g++` again. Please add any error messages to the question by [editing it](https://askubuntu.com/posts/1259617/edit). – N0rbert Jul 16 '20 at 14:57
  • the problem still continues even if I do sudo apt up – John Jul 16 '20 at 15:07
  • 3
    Did you remove some files manually? Try running `sudo apt install --reinstall gcc g++`. Retry your actions. – Kulfy Jul 16 '20 at 15:32
  • 1
    Yes. sudo apt install --reinstall gcc g++ solves my problem, many thanks Kulfy – John Jul 16 '20 at 15:35
  • 2
    @John Is this really a duplicate of [How do I restore the default repositories?](https://askubuntu.com/questions/124017/how-do-i-restore-the-default-repositories), then? As far as I can tell, the solution that actually worked for you--reinstalling the package--is not presented there and would not make sense there. – Eliah Kagan Jul 16 '20 at 16:00

2 Answers2

0

Steps you can try:


  • Try sudo apt update before running sudo apt install g++.
  • Restart the Terminal. (If you connect via SSH, try reconnecting.)
  • Remove the g++ with sudo apt purge g++, and reinstall it.

If you want to know if the package installed, check out this answer.

ahmedg
  • 207
  • 2
  • 11
0

Yes you can check installed tools via this command :

sudo apt list --installed

In your case, "g++" is not installed. Try updating the repositories before installing via these commands :

sudo apt-get update -y && sudo apt-get install g++ -y