title: Static linking libc++ clang
body: <p>I trying to link statically the standard library libc++ (<a href="https://libcxx.llvm.org/" rel="nofollow noreferrer">https://libcxx.llvm.org/</a>) in Linux (Arch using this AUR <a href="https://aur.archlinux.org/packages/libc%2B%2B/" rel="nofollow noreferrer">https://aur.archlinux.org/packages/libc%2B%2B/</a>) using Clang. </p>
  
  <p>I get the error <code>/usr/bin/ld: cannot find -lc++</code></p>
  
  <p>The error is independent from the code, it appears even in a "Hello World".</p>
  
  <p>If I remove the <code>-static</code> option it compiles (and links) and the generated executable works.</p>
  
  <p>I don't want to use libstdc++ (I have my reasons not to please not focus the discussion in this) and the linking must be static (it's a requirement).</p>
  
  <p>I'm perfectly aware that it's difficult to debug this stuff without having access to the machine where it happens. However, it happens it two different machines (both with Arch) so maybe it's something I'm forgetting about.</p>
  
  <p>What I have tried so far is explained here (<a href="https://releases.llvm.org/7.0.0/projects/libcxx/docs/UsingLibcxx.html" rel="nofollow noreferrer">https://releases.llvm.org/7.0.0/projects/libcxx/docs/UsingLibcxx.html</a>)</p>
  
  <p>The basic command that shoud work it's the following
  <code>clang++ -static -stdlib=libc++ -std=c++17 main.cpp -lc++abi</code></p>