问题
I just installed clang++3.6 on my Ubuntu machine, but can't set it as the default c++ compiler.
sudo update-alternatives --config c++
tells me that
There is only one alternative in link group c++ (providing /usr/bin/c++): /usr/bin/g++
Nothing to configure.
and clang++ doesn't show up in
sudo update-alternatives --query c++
either (which was to be expected). But the compiler definitely works:
which clang++-3.6
/usr/bin/clang++-3.6
My OS version is Ubuntu 14.04.1 LTS.
What do I have to do to make update-alternatives
include clang++3.6?
Note: I previously used clang3.4, but removed it since it doesn't support all c++11 feature I require. It seems that this is still the version installed when simply installing the clang++ package (I specifically installed clang++3.6); update-alternatives
DID work for that version.
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/30549502/installed-clang3-6-on-ubuntu-cant-select-as-alternative