Unable to install g++ in ubuntu 20.04 - c++

I have seen some questions similar to this on this website old latest.
But none of them have been answered and I am unable to comment there because I have less reputation points.
When I run sudo apt install g++ I get the following error:
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
g++ : Depends: gcc (= 4:9.3.0-1ubuntu2) but it is not going to be installed
Depends: g++-9 (>= 9.3.0-3~) but it is not going to be installed
Depends: gcc-9 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
When I run sudo apt install build-essential
I get the following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
build-essential : Depends: gcc (>= 4:9.2) but it is not going to be installed
Depends: g++ (>= 4:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I need to install g++ in ubuntu20.04.
Thanks for the help!

I found a work around by installing aptitude first.
I followed the following steps:
sudo apt-get install aptitude
Then aptitude gives a list of packages (none of which were installed)
and asks to keep those packages in the same version. Choose No (n).
Then aptitude asks to downgrade some packages. Choose Yes (Y).
Finally run the command: sudo aptitude install build-essential
After running the above command g++ was already install and I didn't need to separately install it.\

Related

Install libgtk-3-dev on Ubuntu 20.04

I would like to write a GUI in cpp. As far as I know gtk is a nice solution for this. Sadly it appears to me that gtk is no longer available under Ubuntu 20.04. (I am using Xubuntu if this matters)
Executing: sudo apt install libgtk-3-dev
Leads to:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libgtk-3-dev : Depends: gir1.2-gtk-3.0 (= 3.24.20-0ubuntu1) but 3.24.20-1 is to be installed
Depends: libatk-bridge2.0-dev but it is not going to be installed
Depends: libatk1.0-dev (>= 2.15.1) but it is not going to be installed
Depends: libcairo2-dev (>= 1.14.0) but it is not going to be installed
Depends: libfontconfig1-dev but it is not going to be installed
Depends: libgdk-pixbuf2.0-dev (>= 2.40.0) but it is not going to be installed
Depends: libglib2.0-dev (>= 2.57.2) but it is not going to be installed
Depends: libpango1.0-dev (>= 1.41) but it is not going to be installed
Depends: libxi-dev but it is not going to be installed
Depends: libgtk-3-0 (= 3.24.20-0ubuntu1) but 3.24.20-1 is to be installed
E: Unable to correct problems, you have held broken packages.
I added "deb http://archive.ubuntu.com/ubuntu focal-updates main" as suggested and tried again resulting in:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libgtk-3-dev : Depends: libatk-bridge2.0-dev but it is not going to be installed
Depends: libatk1.0-dev (>= 2.15.1) but it is not going to be installed
Depends: libcairo2-dev (>= 1.14.0) but it is not going to be installed
Depends: libfontconfig1-dev but it is not going to be installed
Depends: libgdk-pixbuf2.0-dev (>= 2.40.0) but it is not going to be installed
Depends: libglib2.0-dev (>= 2.57.2) but it is not going to be installed
Depends: libpango1.0-dev (>= 1.41) but it is not going to be installed
Depends: libxi-dev but it is not going to be installed
Depends: libgtk-3-0 (= 3.24.20-0ubuntu1) but 3.24.20-1 is to be installed
E: Unable to correct problems, you have held broken packages.
I am looking for a solution to install libgtk-3-dev.
The problem is that the proper version of the library libgtk-3-dev and related dependencies are not in the main focal repository yet. My solution was to add focal-updates repo. You can do it through GUI (Software&Update) or by manually editing file:
/etc/apt/sources.list
and adding following line:
deb http://archive.ubuntu.com/ubuntu focal-updates main
Then I was able to install the library (I used Synaptic manager) without any problems.
And finally I have disabled the focal-updates repo to stay just with release repo as before, not to automatically update other not-yet-released libraries.
I would first make sure I have all the required dependencies, make sure to install the specific version required. The dependencies can be found here on Ubuntu 's website
If the dependencies can not be found in the apt repository, you can always download the source files for each missing package from their respective websites, and build libgtk from source.
You most likely have a package that's incompatible with one of the others needed installed however it would require a bit more digging to find the root.

trying to install `gdb-multiarch` on ubuntu 18.04

I am trying to install gdb-multiarch on ubuntu 18.04. When I use sudo apt-get install gdb-multiarch, I am getting following error.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gdb-multiarch : Depends: gdb (= 8.1-0ubuntu3.2) but it is not going to be installed
Depends: libpython3.6 (>= 3.6.5) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I couldn't find a way to install above dependencies.
It's probably caused by an installation of a version of python that wasn't included with your Ubuntu install so your package manager is confused about what to do.
This worked for me:
https://askubuntu.com/questions/1061762/ubuntu-18-04-cant-upgrade-because-of-libpython3-6-version-conflicts

Installing g++ 7.0.1 on Debian 8.7

I have been trying for quite some time to install g++ 7 on my Debian machine. I was able to install it quite easily on my mac (as homebrew had a formula for it). However I cannot seem to find a way to install it on Linux.
This individual had a thread on installing g++ 4.9, and changing the url he gave led me to this page, which seems to be in the right direction... But I imagine installing it this way might lead to a few potential problems down the road when I wish to update these packages.
Is there a source I'm missing? Or is there maybe a place where I can download and compile everything I need to get it running?
Thank you for your help.
Helpful Data:
My kernel is x86_64 Linux 3.16.0-4-amd64.
Edit: After following Dietrich's advice, I am now met with a new error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gcc-7 : Depends: cpp-7 (= 7-20170316-1) but it is not going to be installed
Depends: libcc1-0 (>= 7-20170316-1) but it is not going to be installed
Depends: binutils (>= 2.28) but 2.25-5+deb8u1 is to be installed
Depends: libgcc-7-dev (= 7-20170316-1) but it is not going to be installed
Depends: libisl15 (>= 0.15) but it is not installable
Depends: libmpfr4 (>= 3.1.3) but 3.1.2-2 is to be installed
Depends: libstdc++6 (>= 5) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.
This is how my sources.list is set up:
#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free
###### Debian Update Repos
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free
###### For ffmpeg
deb http://www.deb-multimedia.org jessie main non-free
###### For gcc-7 (Experimental)
deb http://httpredir.debian.org/debian experimental main
I'm guessing this is, as you said, a problem with me being on Debian stable? What would I need to do in order to fix this error, while remaining on stable?
Edit 2: Okay, so I figured out that last error. I just had to add go through for every individual dependency that gave my trouble and install it using apt-get install -t testing . Thank you to everyone who replied. You were all very helpful.
You can find similar in the Stack Overflow Unix pages
To install the newest g++ from testing on debian, do the following:
Add debian testing repo to your apt sources by creating a file (with .list extension) on /etc/apt/sources.list.d folder containing the line
deb http://ftp.us.debian.org/debian testing main contrib non-free
Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:
Package: *
Pin: release a=testing
Pin-Priority: 100
You should name the file something like preferences or testingpref,etc. If you have a preferences file, you can add it there. Remove the .unused or any . in the filename.
Update database:
sudo apt-get update
Install g++:
sudo apt-get install -t testing g++
This will give you the most recent version of g++ in the repo. Thus it will receive updates and more-easily reversable. You need to use -t testing to get most recent versions.
You may have dependency issues. It may be in experimental instead of testing for your architecture. See https://packages.debian.org/search?keywords=g%2B%2B
For experimental packages (7 is in there) add:
deb http://httpredir.debian.org/debian experimental main
to /etc/apt/sources.list . Similar to above.. pinning should say a=experimental instead of a=testing and lastly,
sudo apt-get install -t experimental g++
Good luck.
The kernel is irrelevant.
GCC 7 has not been released yet, as you can see in the GCC 7 release notes:
Disclaimer: GCC 7 has not been released yet, so this document is a work-in-progress.
You may want to learn about what makes different Linux distros different. In particular, what a rolling distribution is, and how Debian releases work. In a rolling distribution, all of the packages continually get updated to newer versions. Debian 8.7 (Jessie / stable) is not a rolling distribution. The packages versions are frozen and only updated when necessary, for extra stability. The latest version of GCC on Debian 8.7 is GCC 4.9.
Debian 9.0 (Stretch / testing) is a rolling release, at least until it gets frozen. If you switch your computer to Stretch you will get GCC 6.3.
If you need something newer, you can either switch to Sid (unstable), or pin packages from Sid.
However, GCC 7 is only available in experimental because it hasn't been released yet. You can install a single package from experimental if you like, see Debian Experimental for instructions.
Howto
Add to your /etc/apt/sources.list
https://wiki.debian.org/DebianExperimental
Then
apt-get update
apt-get -t experimental install gcc-7
From the page you must download the g++7 for amd64 deb file. Then, as root, run the following command.
dpkg -i file.deb

Program "g++" not found in PATH on Ubuntu

I have eclipse Luna installed on Ubuntu with no internet connection.
I tried to run the simple "Hello World" program but I encountered the error:
Program "g++" not found in PATH
I downloaded (on another computer and copied it) the g++_4.8.2-1ubuntu6_i386.deb and tried to install it:
sudo dpkg -i g++_4.8.2-1ubuntu6_i386.deb
and I got this error message:
dpkg: dependency problems prevent configuration of g++:i386:
g++:i386 depends on cpp (>= 4:4.8.2-1ubuntu6)
g++:i386 depends on gcc (>= 4:4.8.2-1ubuntu6)
g++:i386 depends on g++-4.8 (>= 4.8.2-5~)
g++:i386 depends on gcc-4.8 (>= 4.8.2-5~)
dpkg: error processing g++:i386 (--install)
How can I install that g++ properly with no internet connection?
I will be happy for some guidance.
You have to connect your computer to internet and update the OS.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Then Try to install g++
You could use apt-offline. You'll need to download and install the deb file using:
dpkg -i apt-offline_1.3.1_all.deb
This program will download dependencies on an online machine, ready for you to copy across to install on your offline machine.
Here's a link on how to use it.

Cannot install Boost library in Ubuntu 12.04

I am trying to install Boost library in my ubuntu 12.04 and always getting the following error:
The following packages have unmet dependencies:
libboost-all-dev : Depends: libboost-iostreams-dev but it is not going to be installed
Depends: libboost-regex-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages
I have search for a solution to the unmet dependencies issue but nothing seems to work. Can some one help with this ?
I'm getting the above error when running sudo apt-get install libboost-all-dev command on my terminal.