I tried to install g++ using packages from another user. offline..but there were errors.
After connecting to the net I tried to install using sudo apt-get install g++
, but it gave the following output:
gstreamer0.10-alsa is already the newest version.
qtdeclarative5-ubuntu-ui-extras-browser-plugin is already the newest version.
python-gconf is already the newest version.
gstreamer0.10-tools is already the newest version.
libglib2.0-0 is already the newest version.
gir1.2-peas-1.0 is already the newest version.
libatk-bridge2.0-0 is already the newest version.
gnome-session-bin is already the newest version.
libgomp1 is already the newest version.
libmessaging-menu0 is already the newest version.
usb-creator-gtk is already the newest version.
libgnome-desktop-3-7 is already the newest version.
software-properties-gtk is already the newest version.
gnome-control-center-shared-data is already the newest version.
unity-scope-gourmet is already the newest version.
libcupsimage2 is already the newest version.
growisofs is already the newest version.
libjson-glib-1.0-common is already the newest version.
activity-log-manager is already the newest version.
libio-string-perl is already the newest version.
qtdeclarative5-qtfeedback-plugin is already the newest version.
gnome-power-manager is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
and many more lines like this….but g++ is still not installed
Best Answer
Apparently
apt-get
doesn't know aboutgcc
.If
apt-get
knows about a package whose name isg++
, it won't attempt to to interpretg++
as anything but the name of a single package. (In contrast, I can reproduce the behavior you're seeing by attempting to install the similarly named nonexistent packageq++
.)There are two likely causes of
apt-get
not knowing about the g++ package:g++
package is configured to be used.g++
is configured to be used but the information about what packages are available for installation hasn't been updated since then.If it were the second reason, you could just run
sudo apt-get update
. But I think it's more likely the first one.Make sure main is enabled.
g++
is provided in the main repository component. This should pretty much always be enabled, but perhaps it is not.Many of the packages necessary for a working Ubuntu system are provided by the main component (this is the software maintained directly by Canonical rather than by the larger community, and it consists mostly of core software important to many Ubuntu systems). Furthermore, some of the packages
apt-get
listed as installed, such aspython-gconf
, are in main.So I think what happened was that main got disabled recently, probably by accident.
apt-get
knows about software from main that is currently installed because it can see that it's installed. But if main is disabled,apt-get
doesn't know about any software from main that you don't have.To check if main is enabled, and re-enable it if it's not, open Software & Updates (called Software Sources on previous versions of Ubuntu). One way to open this is to click the Settings... button in the Software Updater (called the Update Manager in old versions of Ubuntu).
Then make sure the box labeled "Canonical-supported free and open-source software (main)" is checked.
If it already was, then most likely I have guessed wrong about the cause of your problem. If it was not already checked, check the box (you may need to enter your password) and click Close. You'll be told "The information about available software is out of date"; click the Reload button.
Then try installing
g++
again.Try a different APT mirror.
If the main component was already enabled, maybe there's something wrong with the APT mirror you're using. Especially if you're not using one of the official mirrors (
us.archive.ubuntu.com
, withus
replaced with your "country code"), I recommend trying a different mirror, an official one if possible.You can set your APT mirror in Software & Updates as well. Just change it in the drop-down menu labeled "Download from".
As when enabling a software source, when you quit Software & Updates after changing your download server, you'll be prompted that software information is out of date and you should click Reload. Then see if
g++
can be installed.Further troubleshooting.
If it still can't be installed, then you should edit your question with more information to help troubleshoot the problem.
/etc/apt/sources.list
. One way to do this is to copy the complete output of the commandcat /etc/apt/sources.list
and paste it into your question. Select it and press Ctrl+K to format it properly.