How can I install multiple versions of llvm libc++ on the same computer at the same time (ubuntu)?

Viewed 1643

I've tried the obvious:

apt-get install -y clang++-7 libc++abi-7-dev libc++-7-dev
apt-get install -y clang++-8 libc++-8-dev libc++abi-8-dev
apt-get install -y clang++-9 libc++-9-dev libc++abi-9-dev
apt-get install -y clang++-10 libc++-10-dev libc++abi-10-dev

No problem with multiple versions of clang++. But each version of libc++ appears to uninstall the previous.

When I try:

apt-get install libc++abi-7-dev libc++-7-dev  libc++abi-8-dev libc++-8-dev libc++-9-dev libc++abi-9-dev libc++-10-dev libc++abi-10-dev

I get

The following packages have unmet dependencies:
 libc++-10-dev : Conflicts: libc++-x.y-dev
 libc++-7-dev : Depends: libc++1-7 (= 1:7.0.1-12) but it is not going to be installed
                Conflicts: libc++-x.y-dev
 libc++-8-dev : Depends: libc++1-8 (= 1:8.0.1-9) but it is not going to be installed
                Conflicts: libc++-x.y-dev
 libc++-9-dev : Depends: libc++1-9 (= 1:9.0.1-11ubuntu1) but it is not going to be installed
                Conflicts: libc++-x.y-dev
 libc++abi-10-dev : Conflicts: libc++abi-x.y-dev
 libc++abi-7-dev : Depends: libc++abi1-7 (= 1:7.0.1-12) but it is not going to be installed
                   Conflicts: libc++abi-x.y-dev
 libc++abi-8-dev : Depends: libc++abi1-8 (= 1:8.0.1-9) but it is not going to be installed
                   Conflicts: libc++abi-x.y-dev
 libc++abi-9-dev : Depends: libc++abi1-9 (= 1:9.0.1-11ubuntu1) but it is not going to be installed
                   Conflicts: libc++abi-x.y-dev
E: Unable to correct problems, you have held broken packages.

Now I'm trying this on ubuntu 20.04, but I've tried similar on past versions of Ubuntu, and run into basically the same problem.

1 Answers

Using docker or a virtualmachine seems to be the only practical solution for this.

You can create build images of different version using the ubuntu:20.04 base image. To build image create different Dockefiles as

Dockerfile.vX (Replace X with the different version numbers)

FROM ubuntu:20.04

RUN apt-get install -y clang++-X libc++abi-X-dev libc++-X-dev

CMD ['/bin/bash']

then build the image of the version X docker build -f Dockerfile.vX -t lewisP/lvvm:X .

and run it as containers docker run -it lewisP/lvvm:X

Read up on volumes to mount your project files you want to work with the installed packages.

Related