Installed clang++3.6 on Ubuntu, can't select as alternative

跟風遠走 提交于 2019-12-02 15:54:15
Huy Le

These work for me:

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.6 100

Since clang is referenced directly as well as via cc, I would break this up into alternatives for clang, and alternatives for cc. After clang is set up below:

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100

To select the version of clang, and cc:

sudo update-alternatives --config clang
sudo update-alternatives --config clang++
sudo update-alternatives --config cc
sudo update-alternatives --config c++

Setting up clang/clang++. Multiple versions of clang are packaged with Ubuntu. In 15.10, for example:

clang-3.4 - C, C++ and Objective-C compiler (LLVM based)
clang-3.5 - C, C++ and Objective-C compiler (LLVM based)
clang-3.6 - C, C++ and Objective-C compiler (LLVM based)
clang-3.7 - C, C++ and Objective-C compiler (LLVM based)

The highest priority alternative is auto, and the rest are manually selected. So if my default were to be the latest, and 4 versions were installed:

sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.7 370
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.7 370
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 360
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 360
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.5 350
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.5 350
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.4 340
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.4 340

If you apply the same to LLDB, you have a fairly complete development environment that includes cross-compilers/debuggers for several architectures. ('fairly' means that the linker, LLD, is not quite mature enough to say complete).

Note: LLDB + Python-LLDB are needed for a complete debugger. Multiple versions of python-lldb CANNOT be installed together, so the best option at this point is to pick the latest version of LLDB with it's associated python package.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!