How to specify custom libc++

社会主义新天地 提交于 2020-12-30 09:45:36

问题


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?


回答1:


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...}



来源:https://stackoverflow.com/questions/51839921/how-to-specify-custom-libc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!