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:

fez@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:
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

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 like before because I need it for my work. 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


I am sorry but it seems that my reputation on ask ubuntu is not high enough to post all the links to the informations I'm providing about the packages and their dependencies. I can provide them later or in comments if you need them. Anyways it's enough to look on packages.ubuntu.com and search for the exact package names I provided to find them.

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.

I have already tried to install the version that have conflicts in chroot, and it seems to work, but I'd really 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.

1 Answer 1


Well, what I do is to use docker or LXD container to create "Compiler-Hosts" to avoid such problems. May this works also for you ?

  • Well, in practice it may work. But ideally I'd like to be able to install everything natively and to manage the packages with apt as I normally do. I love apt (except when things like this happen :) ). If it's not possible with the upstream repositories I'd prefer a deb package with the proper dependencies met. Or even a ppa it would be ok. I've never had the need to use docker, but I don't think that with docker I can manage the containers with apt, isn't it? If nothing else works out, then I can consider docker, but I want to know all the possible viable options before giving up.
    – fez
    Aug 4, 2016 at 18:13
  • Yes you can use apt and other packet managers. You create a kind of "Makefile"for docker to create the docker container and there you can use "apt" to install the software. Here a exampe "docs.docker.com/engine/userguide/eng-image/…" or use LXC (see: insights.ubuntu.com/2016/04/01/lxd-2-0-image-management-512) and you have a classic running system like a VM where you can install software with apt and save the whole image after having everything done.
    – 0x0C4
    Aug 5, 2016 at 6:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .