I need a newer G++ for a project, but all tutorials will tell you to download the sources, compile them and "simply" install them then use it. Which is something I don't want since it's not very reproducible.

However, Debian do have more recent packages in their repositories (bullseye, testing, unstable, etc) that I can keep and share. I know doing this will almost get me a FrankenDebian, but it's far better than going the sources way or any shady repository (some tutorials even suggest ppas for Debian...).

I also want to keep Debian buster's G++, since a lot of things will surely use it and that avoiding such errors:

/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.30' not found (required by /lib/x86_64-linux-gnu/libselinux.so.1)

error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

would certainly prevent some headaches here.

I also heard about setting alternatives and all, but I would need to install the right packages first.

So here's my question: How do I install another G++ on Debian buster, without going the sources' way ?

  • 1
    How about schroot? It's easy and fast. Containers or VMs are heavier solutions.
    – Krackout
    Commented May 5, 2021 at 12:45
  • 1
    Note that it’s glibc that’s at version 2.28, not G++. Commented May 5, 2021 at 15:27
  • 1
    "Debian" compilers, mostly created with Ubuntu 16.04 for easy install to all later Debian / Ubuntu versions drive.google.com/drive/folders/… .... .... Which version do you prefer ? ( I have extra computers to create compilers / .deb and rpm packages.) .... Please suggest Debian OS version. Commented May 5, 2021 at 17:24
  • 1
    Please note that you can have as many gcc/g++ versions as you want, installed at the same time. Never remove the system compiler. ... OK, Debian 10 Buster + gcc-9.3.0 : No official packages. But easy to build gcc-9.x or 10. x as extra unofficial drive.google.com/drive/folders/… Commented May 6, 2021 at 21:50
  • 1
    Meanwhile a new package was built drive.google.com/file/d/1io8oWdMupAUK_QXkGB928RmqeSt-5FuQ/… ... Ref. stackoverflow.com/questions/67431292/… .... .... which you of course are most welcome to test. ... ... Works perfect with Debian 10 Buster. Commented May 8, 2021 at 18:35

1 Answer 1


This is currently possible (and will no doubt remain so, since Debian 11 is frozen prior to release), as long as you only need gcc (and not g++). You’ll need to add Buster backports and Bullseye to your sources, and configure pinning appropriately, for example

Package: *
Pin: release n=buster
Pin-Priority: 500

Package: *
Pin: release n=buster-updates
Pin-Priority: 500

Package: *
Pin: release n=buster-backports
Pin-Priority: 110

Package: *
Pin: release n=bullseye
Pin-Priority: 100

Then you can install gcc-10, which won’t require any upgrade of either libc6 or libstdc++6. apt has trouble resolving the dependencies, but aptitude manages just fine, and they’re contained (22 upgraded packages in my tests, the majority of which are GCC or binutils packages).

g++-10 is a different story; it requires a newer libstdc++6, and upgrading that essentially involves upgrading to testing.

As you say though this would result in a “FrankenDebian”, so you might want to look into setting up a Debian testing schroot or using a debian:11 container instead.

  • Just asked, g++ is also needed. Sigh. schroot seems to be complicated for compiling big projects and going with containers looks even more. That's even without considering huge performance penalties which can sometimes raises tenfold, and the maintainence burden (fekir.info/post/docker-process-creation-overhead-when-compiling , fekir.info/post/chroot-as-docker-alternative-for-building ). Looks like VMs are the way to go: performance penalties are around 1.25x starting with Sandy Bridge CPUs and even less after those, easy maintainability at the cost of more RAM usage.
    – X.LINK
    Commented May 5, 2021 at 15:00
  • The approach used in those posts for building in a container is rather strange — starting a container every time the compiler is needed is always going to result in a hefty penalty. Running the full build in a container doesn’t cost much in performance, much less than a VM; I do that every day. Commented May 5, 2021 at 15:29

You must log in to answer this question.

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