unresolved_external
unresolved_external

Reputation: 2018

How to specify custom libc++

I have built libc++ and want to use it when compiling my program ? so I have something like

clang++ -stdlib=~/libc++/libc++.so main.cpp

but this does not work. How can use my custom built libc++ when building the application?

Upvotes: 7

Views: 5240

Answers (1)

Clonk
Clonk

Reputation: 2070

This information comes from llvm documentation about libcxx.

If you want to use a custom libc++ with clang you have to specify argument like this :

$ clang++ -std=c++11 -stdlib=libc++ -nostdinc++ -I<path_to_libcxx>/include/c++/v1 -L<path_to_libcxx>/lib -Wl,-rpath,<path_to_libcxx>/lib main.cpp ${end_of_compile_line...}

Alternatively, you can put the path of your library in LD_LIBRARY_PATH (assuming you are under Linux) :

export LD_LIBRARY_PATH=<libcxx-install-prefix>/lib:$LD_LIBRARY_PATH

and compile using simply these options :

$ clang++ -stdlib=libc++ -nostdinc++ -I<path_to_libcxx>/include/c++/v1 -L<path_to_libcxx>/lib main.cpp -o ${end_of_compile_line...}

Upvotes: 6

Related Questions