Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable libc++/libcxx by default when using clang++

Tags:

I installed clang from scratch following the instructions here. Afterwards, I installed libc++ using libsupc++ according to the instructions here.

Now, whenever I compile & link a program with clang and libc++, I need to issue a command like that:

clang++ -stdlib=libc++ -Wl,-rpath,/path/to/libcxx/lib <...> 

Is there a way to configure/compile clang in a way that it uses libc++ by default, without me having to specify the library and/or the path on the command line each time? Putting it into LD_LIBRARY_PATH is not a preferred option either, neither is using a custom wrapper script.

like image 244
Michael Schlottke-Lakemper Avatar asked Nov 11 '13 07:11

Michael Schlottke-Lakemper


People also ask

Which libc does clang use?

One can also use clang with Microsoft Visual Studio C and C++ libraries.

How do I know if libc ++ is installed?

Type ldconfig -p | grep libc++ into the terminal. It does not matter what system you are using. If libc++ is not installed, the terminal will not say anything. If it is installed, it will display the available versions.

What is libc ++ abi?

libc++abi is a new implementation of low level support for a standard C++ library. All of the code in libc++abi is dual licensed under the MIT license and the UIUC License (a BSD-like license).

Does clang use Libstdc ++?

Clang supports use of either LLVM's libc++ or GCC's libstdc++ implementation of the C++ standard library.


1 Answers

Clang's CMake build system learned the CLANG_DEFAULT_CXX_STDLIB to set the default C++ standard library.

However, I don't know how practicable this solution is for you, because you have to use a top of tree build until next clang/llvm release.

like image 148
Michael Haidl Avatar answered Sep 21 '22 05:09

Michael Haidl