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

后端 未结 2 389
一个人的身影
一个人的身影 2021-01-30 17:47

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

相关标签:
2条回答
  • 2021-01-30 18:28

    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
    
    0 讨论(0)
  • 2021-01-30 18:36

    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.

    0 讨论(0)
提交回复
热议问题