`g++` commands isn't working and APT is reporting `g++` is installed

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

5

2 Answers

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 outthis answer.

2

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like