title: Unable to use libc++ with clang++-5.0
body: <p>I've installed clang++-5.0 to try out new C++17 features, but to get the full experience I need a new library. After being unable to find newer libstdc++, I decided to try out libc++.</p>
  <p>I've checked it out using similar way described <a href="http://llvm.org/docs/GettingStarted.html#checkout" rel="nofollow noreferrer">here</a>.</p>
  <p>After checkout, I've compiled it with clang itself, since it was advised to use clang. Compilation went without problems. Then I installed it, make put them in the <code>/usr/local/include/c++/v1</code> directory.</p>
  <p>When I tried to compile anything, I was getting an error saying the compiler couldn't find <code>&lt;stddef.h&gt;</code>. I solved the problem with &quot;redirecting&quot; the includes: <code>-isystem /usr/local/include/c++/v1</code>.</p>
  <p>But then linker throws a lot of errors related to exceptions and virtual tables. I have no idea what to do in this case.</p>
  <p>Is it possible to fix it?</p>
  <p>My setup: ubuntu 16.04 LTS with all updates, clang++-5.0, cmake-3.6 .</p>
  <p>Here are my flags:</p>
  <pre><code>set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -v -stdlib=libc++ -Wall -Wextra -pedantic-errors -std=c++1z -isystem /usr/local/include/c++/v1&quot;)
  </code></pre>
  <p>Excerpt from error messages:</p>
  <pre><code>//usr/local/lib/libc++.so: undefined reference to `__cxa_end_catch'
  //usr/local/lib/libc++.so: undefined reference to `__cxa_pure_virtual'
  //usr/local/lib/libc++.so: undefined reference to `__cxa_rethrow'
  //usr/local/lib/libc++.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
  //usr/local/lib/libc++.so: undefined reference to `vtable for __cxxabiv1::__class_type_info'
  //usr/local/lib/libc++.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
  </code></pre>
  <p><strong>UPDATE:</strong></p>
  <p>After building libc++abi it successfully passes build step, though now it crashes with error saying</p>
  <blockquote>
  <p>error while loading shared libraries: libc++abi.so.1: cannot open shared object file: No such file or directory</p>
  </blockquote>
  <p>Current flags:</p>
  <pre><code>set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -isystem /usr/local/include/c++/v1 -stdlib=libc++ -lc++abi -Wall -Wextra -pedantic-errors -std=c++1z&quot;)
  </code></pre>
  <p>After having a look, I found that they are absent in <code>/usr/lib/</code>, but are present in <code>/usr/local/lib</code>.</p>
  <p>Here is the output of <code>ldd program</code>:</p>
  <blockquote>
  <p>linux-vdso.so.1 =&gt;  (0x00007ffd1b7da000)</p>
  <p>libc++abi.so.1 =&gt; /usr/local/lib/libc++abi.so.1 (0x00007f69bd322000)</p>
  <p>libc++.so.1 =&gt; /usr/local/lib/libc++.so.1 (0x00007f69bcf80000)</p>
  <p>libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f69bcc76000)</p>
  <p>libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f69bca60000)</p>
  <p>libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f69bc697000)</p>
  <p>libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f69bc479000)</p>
  <p>librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007f69bc271000)
  /lib64/ld-linux-x86-64.so.2 (0x000055e63a9a9000)</p>
  </blockquote>