更新时间:2023-02-26 21:48:35
此信息来自 llvm有关libcxx的文档.
如果要对clang使用自定义libc ++,则必须指定如下参数:
$ 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 ...}
或者,您可以将库的路径放在LD_LIBRARY_PATH中(假设您在Linux下):
export LD_LIBRARY_PATH =< libcxx-install-prefix>/lib:$ LD_LIBRARY_PATH
并仅使用以下选项进行编译:
$ clang ++ -stdlib = libc ++ -nostdinc ++ -I< path_to_libcxx>/include/c ++/v1 -L< path_to_libcxx>/lib main.cpp -o $ {end_of_compile_line ...}
>
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?
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...}