You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04下多版本Clang/LLVM冲突致命令执行失败求助

Fixing Clang "Option 'help-list' registered more than once" Error on Ubuntu 20.04

Hey there, I get it—switching from GCC to Clang can be a hassle, especially when you run into weird library conflicts like this. Let's break down how to fix this system-wide so you can use Clang directly without build tool workarounds.

Root Cause

The error happens because your system has multiple conflicting versions of LLVM/Clang libraries installed: you've got clang-10 (the main version you want) alongside libc++-7 and its associated libraries. These old libraries are clashing with the newer LLVM 10 components, causing duplicate command-line option registrations.

System-Wide Fix Solutions

This is the most straightforward fix—remove the outdated libc++ 7 packages that are causing the conflict, then ensure Clang 10 is set as your default:

  1. Uninstall the old libc++ 7 packages completely:

    sudo apt remove --purge libc++-7-dev libc++1-7 libc++abi-7-dev libc++abi1-7
    sudo apt autoremove --purge
    

    The autoremove command will clean up any leftover dependencies tied to these packages.

  2. Set Clang 10 as the system's default clang/clang++:

    sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 100
    sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-10 100
    

    The 100 here gives it priority over any other versions that might be installed.

  3. Verify the fix:
    Run clang --version—you should see output for Clang 10.0.0, and the error should be gone. Test a simple compile with clang -c test.c to make sure everything works.

Solution 2: Isolate Libraries with Environment Variables (If You Need Old Versions)

If you absolutely have to keep the libc++ 7 libraries for another project, you can force Clang to only use the LLVM 10 libraries by setting the LD_LIBRARY_PATH:

  1. Temporarily set the path for your current terminal session:

    export LD_LIBRARY_PATH=/usr/lib/llvm-10/lib:$LD_LIBRARY_PATH
    
  2. Make it permanent by adding it to your shell config:
    For Bash:

    echo 'export LD_LIBRARY_PATH=/usr/lib/llvm-10/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
    source ~/.bashrc
    

    For Zsh:

    echo 'export LD_LIBRARY_PATH=/usr/lib/llvm-10/lib:$LD_LIBRARY_PATH' >> ~/.zshrc
    source ~/.zshrc
    
  3. Verify:
    Run clang --version and a test compile to confirm no more errors.

Solution 3: Full Reinstall of Clang (For Stubborn Cases)

If the above methods don't work, a full clean reinstall will wipe out all conflicting components:

  1. Purge all Clang/LLVM related packages:

    sudo apt remove --purge clang clang-10 llvm-10* libclang-10* libc++*
    sudo apt autoremove --purge
    sudo apt clean
    
  2. Reinstall Clang 10:

    sudo apt update
    sudo apt install clang-10
    
  3. Set it as the default again:

    sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 100
    sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-10 100
    

Final Notes

Sticking with Solution 1 is best long-term—having mismatched LLVM/libc++ versions is a recipe for future issues. Once you've fixed this, you should be able to use Clang directly from the terminal without any build tool hacks.

内容的提问来源于stack exchange,提问作者Lahiru Udayanga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:20:30