How to install both gcc-4.7-plugin-dev and gcc-4.8-plugin-dev on Ubuntu 16.04 without conflicts?

Asked by pfez on 2016-08-04

I have just installed Ubuntu 16.04 Xenial on the laptop I use for development.

I am currently working on a plugin for gcc and I want my plugin to be compatible with several different versions of the compiler (currently from `gcc-4.6` to `gcc-6`). For this reason I need several different versions of the compiler and of the plugin headers installed on my development workstation at the same time, so that I can build the plugin against the different versions. This worked like a charm with the old LTS 14.04, but with the new LTS I have a problem I can't solve.

I can easily install all the version of gcc from `gcc-4.7` to `gcc-5` from the default repository, but when I try start installing the `gcc-*-plugin-dev` packages I run into troubles. Basically everything is fine if I install only `gcc-4.8-plugin-dev`, `gcc-4.9-plugin-dev` and `gcc-5-plugin-dev`. After that if I try to install `gcc-4.7-plugin-dev` I get the following:

    user@vbox1604:~$ sudo apt install gcc-4.7-plugin-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following additional packages will be installed:
      libgmpv4-dev
    Suggested packages:
      gmp-doc libgmp10-doc libmpfr-dev
    The following packages will be REMOVED:
      gcc-4.8-plugin-dev gcc-4.9-plugin-dev gcc-5-plugin-dev libgmp-dev libmpc-dev libmpfr-dev
    The following NEW packages will be installed:
      gcc-4.7-plugin-dev libgmpv4-dev
    0 upgraded, 2 newly installed, 6 to remove and 0 not upgraded.
    Need to get 1003 kB of archives.
    After this operation, 15.0 MB disk space will be freed.
    Do you want to continue? [Y/n] n
    Abort.
    user@vbox1604:~$

As you can see it does not let me install the package if I don't remove the others. The problem seems to be the fact that the different versions of gcc rely on different versions of `libgmp`. If fact `gcc-4.8-plugin-dev` and higher require the package `libgmp-dev`, while `gcc-4.7-plugin-dev` requires `libgmpv4-dev`. These last two are actually two separate packages and they are at the origin of the conflict.

This seemed very strange to me, since in Ubuntu 14.04 everything worked just fine. Hence I decided to take a look on packages.ubuntu.com
Here is what I found out:

1. about `libgmp-dev` and `libgmpv4-dev`

    * on Ubuntu 14.04 `libgmpv4-dev` does not exist and all the versions of `gcc-*-plugin-dev` depend on `libgmp-dev`
    * on Ubuntu 16.04 there are two separate packages `libgmp-dev` and `libgmpv4-dev`. Apparently, the only difference between the two of them is that the former stays in the `main` repository while the latter is in `universe`.
    * for `libgmp-dev` the dependencies are the same in both Ubuntu 14.04 and 16.04
    * `libgmpv4-dev` on Ubuntu 16.04, instead, depends on basically the same packages, but the naming and the versions are slightly different than those in `libgmp-dev`. And `libgmpv4-dev` reports "(GCC 4.x compatible)" in its description. But I don't understand why this is significant, since gcc-4.8 is in the 4.x series but it works perfectly fine with the (non-4.x-compatible?) `libgmp-dev`. And until Ubuntu 14.04 also gcc-4.7 worked with just `libgmp-dev` so I don't understand what has changed.

2. about `gcc-4.7-plugin-dev` and `gcc-4.8-plugin-dev`

    * on Ubuntu 14.04 they depend on the same version of libgmp: `libgmp-dev`
    * on Ubuntu 16.04 it's not clear why, but they start to have different dependencies, as I showed you on the terminal:
        - `gcc-4.7-plugin-dev` depends on `libgmpv4-dev`
        - `gcc-4.8-plugin-dev` depends on `libgmp-dev`

Does anybody of you have any idea about why things are this way? Do you know if and how I can install both the versions `gcc-4.7-plugin-dev` and `gcc-4.8-plugin-dev` on the same machine with Ubuntu 16.04? I am not a ninja of apt dependencies but something looks strange to me, and I really need this to work because I need it for my job. Otherwise I have to roll back to 14.04 (or keep the older version of gcc in chroot, but I'd like to avoid it if possible).

Thanks in advance

fez

P.S.
I know that there exist a ppa for the gcc toolchain ( https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/ppa ) and I also tried to add it to my sources. It enables me to install a wider range of gcc versions (from `gcc-4.5` to `gcc-6`) but it does not fix the problem nor it changes anything with the conflicts.

P.P.S.
I have also tried to install the version that have conflicts in chroot, and it seems to work, but I really would like to know if there's a way to fix this dependency problem without dirty tricks. In principle I'd like to find a way to make the installation manageable with apt.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gcc-4.7 Edit question
Assignee:
No assignee Edit question
Last query:
2016-08-04
Last reply:
2016-08-05
Manfred Hampl (m-hampl) said : #1

I am no developer and cannot provide any information on the background of that packaging conflict, but maybe I can point you in the direction of a workaround.

libgmpv4-dev has in its control file "Conflicts: libgmp-dev", and consequently the packages libgmp-dev and libgmpv4-dev as provided in the standard Ubuntu repositories cannot be installed at the same time.

I now spotted a version of libgmpv4-dev in a PPA with the control entries "Conflicts: libgmp-dev ..." and "Provides: libgmp-dev ..."
This should allow installing gcc-4.7-plugin-dev and gcc-4.8-plugin-dev at the same time by providing the dependencies for both.

see https://launchpad.net/~sbeattie/+archive/ubuntu/gcc-pie-amd64

Remark, I am writing that based on package information and have not tested that myself, neither whether the installation really works nor if all programs are then correctly functioning.

Second remark, I do not know why the PPA version can have "Provides: libgmp-dev ..." in its control settings, but the standard Ubuntu version doesn't.

Can you help with this problem?

Provide an answer of your own, or ask pfez for more information if necessary.

To post a message you must log in.