sudo apt-get install build-essential
I tried this.

No candidate version found for g++.

No packages will be installed.

Can someone help me?

Thanks

Dani AI

Generated

Short answer: the package database on the machine can't see a repository that actually contains the g++ binary. That usually happens because /etc/apt/sources.list has malformed or incomplete lines (so the "main" archive is not enabled) or because the Ubuntu release in use has been moved off the regular mirrors (EOL) and its archive has been relocated.

What to check (quick diagnostics)

  • Confirm the release codename and which sources are currently active. Run these and inspect the output to see what codename you have and which lines apt will actually use:
lsb_release -sc
grep -Ev '^\s*#|^\s*$' /etc/apt/sources.list
apt-cache policy g++

Common fixes

  • If your sources.list contains a stray token like a lone "main restricted" line (not starting with deb), that line is invalid — repository lines must start with deb and include the mirror, codename and components. Edit the file as root after making a backup, and ensure you have at least the main and security repositories enabled for your codename.
  • If the release is no longer supported (EOL), change the mirror entries to the old-releases archive for that codename instead of the normal mirrors, or better: upgrade to a currently supported Ubuntu release.

Example repository lines (replace the codename shown by the lsb_release -sc result or switch to old-releases if EOL):

deb http://archive.ubuntu.com/ubuntu/ intrepid main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ intrepid-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu intrepid-security main restricted universe multiverse

Notes tied to thread posts

  • was right to ask for the sources.list — the file contents are the key. ’s suggestion to install g++ will only work once the repositories are correct. ’s CD suggestion can work offline, but fixing online repositories (or moving to old-releases) is a cleaner long‑term solution. Make a backup of /etc/apt/sources.list before editing.

Recommended Answers

All 9 Replies

Member Avatar for Member #46692

For want of sounding obvious?

sudo apt-get install g++?

What have you got in the /etc/apt/sources.list file? Have you run 'sudo apt-get update' before trying to install build-essential?

commented: good points +18

For want of sounding obvious?

sudo apt-get install g++?

Pakage g++ is not available, but is ref. to by another pkg. This may mean that the pkg is missing, has been obsoleted or is available from another source.
E : Pkg g++ has no installation candidate.

I also tried going thru the pkg manager (GUI tool). There were g++ pkges, I tried installing them from the list. But I got the error msg : Not installable.

Thanks

What have you got in the /etc/apt/sources.list file? Have you run 'sudo apt-get update' 'sudo apt-get update' before trying to install build-essential?

I ran the 'sudo apt-get update' .

Then I tried sudo apt-get install g++
It says : Pkg g++ is not available but is referred to by another pkg.
This may mean that the pkg is missing /obsoleted or is only available from another source.

Pkg G++ has no installation candidate.

Thanks

These are the steps I executed :

1. I ran the 'sudo apt-get update' .

2. Then I tried sudo apt-get install g++

the error message : Pkg g++ is not available but is referred to by another pkg.This may mean that the pkg is missing /obsoleted or is only available from another source.
Pkg G++ has no installation candidate.
end of error message

So what's in your /etc/apt/sources.list file?

Yes I did it !
Thanks

I ran the 'sudo apt-get update' .

Then I tried sudo apt-get install g++
It says : Pkg g++ is not available but is referred to by another pkg.
This may mean that the pkg is missing /obsoleted or is only available from another source.

Pkg G++ has no installation candidate.

Thanks

hello
use this
$sudo gedit /etc/apt/sources.list
when the file opened put # as the first charactre of each line save file
and put ubuntu installation cd to optical drive
then try this and it will solve your problem
$sudo apt-get install g++

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.