{"id":28059,"date":"2023-01-14T04:15:56","date_gmt":"2022-11-09T07:33:06","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/"},"modified":"2025-08-12T06:08:02","modified_gmt":"2025-08-11T22:08:02","slug":"%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/","title":{"rendered":"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++"},"content":{"rendered":"<h2>\u8fd9\u662f\u4ec0\u4e48\uff1f\u5728\u4f7f\u7528Ubuntu\u4e0a\u7684clang\u7f16\u8bd1\u5668\u8fdb\u884cC++\u5f00\u53d1\u65f6\uff0c\u6211\u4eec\u5e38\u5e38\u4f7f\u7528\u7684\u662f\uff08GNU\u5de5\u5177\u94fe\u7684\uff09libstdc++\u800c\u4e0d\u662f\uff08LLVM\u7684\uff09libc++\u3002\u4e5f\u8bb8\u4f60\u53ef\u80fd\u8ba4\u4e3a\u8fd9\u662f\u7406\u6240\u5f53\u7136\u7684\uff0c\u4f46\u5b9e\u9645\u4e0a\u60c5\u51b5\u5e76\u975e\u5982\u6b64\u3002<\/p>\n<p>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0c\u6211\u8fd8\u8c03\u67e5\u4e86\u5176\u4ed6\u8fd0\u884c\u5e93\u7684\u5207\u6362\u65b9\u6cd5\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u5173\u4e8e\u8fd9\u4e2a\u9886\u57df\u7684\u5b98\u65b9\u6587\u4ef6\u3002\u8bf7\u70b9\u51fb\u4ee5\u4e0b\u94fe\u63a5\u67e5\u770b\u3002<br \/>\nhttps:\/\/clang.llvm.org\/docs\/Toolchain.html#runtime-libraries<\/p>\n<h2>\u73af\u5883\u8fd9\u662f\u5728 Ubuntu 18.04 \u4e0a\u6309\u7167LLVM\u7684\u6807\u51c6\u6b65\u9aa4\u5b89\u88c5\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>bash -c \"$(wget -O - https:\/\/apt.llvm.org\/llvm.sh)\"\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>$ clang++-10 --version\r\nclang version 10.0.1-++20200507062652+bab8d1790a3-1~exp1~20200507163249.158\r\nTarget: x86_64-pc-linux-gnu\r\nThread model: posix\r\nInstalledDir: \/usr\/bin\r\n<\/code><\/pre>\n<h2>\u6307\u5b9a\u306a\u3057\u7c21\u5358\u306a\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002(\u4f8b\u5916\u304c\u767a\u751f\u3057\u3046\u308b\u30b3\u30fc\u30c9\u306b\u3057\u3066\u3042\u308a\u307e\u3059)<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">#include &lt;cstdio&gt;\r\n#include &lt;string&gt;\r\n<\/span><span class=\"kt\">int<\/span> <span class=\"nf\">main<\/span><span class=\"p\">()<\/span> <span class=\"p\">{<\/span> <span class=\"n\">puts<\/span><span class=\"p\">(<\/span><span class=\"n\">std<\/span><span class=\"o\">::<\/span><span class=\"n\">string<\/span><span class=\"p\">(<\/span><span class=\"s\">\"hello\"<\/span><span class=\"p\">).<\/span><span class=\"n\">c_str<\/span><span class=\"p\">());<\/span> <span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u30fb\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ clang++-10 test.cc\r\n$ .\/a.out\r\nhello\r\n<\/code><\/pre>\n<p>\u4f55\u3082\u4e0d\u601d\u8b70\u306f\u306a\u3044\u3067\u3059\u306d\u3002 -v \u3092\u3064\u3051\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>\r\n$ clang++-10 -v test.cc\r\nclang version 10.0.1-++20200507062652+bab8d1790a3-1~exp1~20200507163249.158\r\nTarget: x86_64-pc-linux-gnu\r\nThread model: posix\r\nInstalledDir: \/usr\/bin\r\nFound candidate GCC installation: \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7\r\nFound candidate GCC installation: \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\r\nFound candidate GCC installation: \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/8\r\nFound candidate GCC installation: \/usr\/lib\/gcc\/x86_64-linux-gnu\/7\r\nFound candidate GCC installation: \/usr\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\r\nFound candidate GCC installation: \/usr\/lib\/gcc\/x86_64-linux-gnu\/8\r\nSelected GCC installation: \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n \"\/usr\/lib\/llvm-10\/bin\/clang\" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.cc -mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1 -internal-isystem \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/c++\/7.5.0 -internal-isystem \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/x86_64-linux-gnu\/c++\/7.5.0 -internal-isystem \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/x86_64-linux-gnu\/c++\/7.5.0 -internal-isystem \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/c++\/7.5.0\/backward -internal-isystem \/usr\/local\/include -internal-isystem \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/include -internal-externc-isystem \/usr\/include\/x86_64-linux-gnu -internal-externc-isystem \/include -internal-externc-isystem \/usr\/include -fdeprecated-macro -fdebug-compilation-dir \/home\/ohta\/projects\/hagoromo\/hgrm.tools.ci\/generic\/config\/docker -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o \/tmp\/test-593447.o -x c++ test.cc\r\nclang -cc1 version 10.0.1 based upon LLVM 10.0.1 default target x86_64-pc-linux-gnu\r\nignoring nonexistent directory \"\/include\"\r\nignoring duplicate directory \"\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/x86_64-linux-gnu\/c++\/7.5.0\"\r\n#include \"...\" search starts here:\r\n#include &lt;...&gt; search starts here:\r\n \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/c++\/7.5.0\r\n \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/x86_64-linux-gnu\/c++\/7.5.0\r\n \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/..\/include\/c++\/7.5.0\/backward\r\n \/usr\/local\/include\r\n \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/include\r\n \/usr\/include\/x86_64-linux-gnu\r\n \/usr\/include\r\nEnd of search list.\r\n \"\/usr\/bin\/ld\" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker \/lib64\/ld-linux-x86-64.so.2 -o a.out \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/crt1.o \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/crti.o \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/crtbegin.o -L\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0 -L\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu -L\/lib\/x86_64-linux-gnu -L\/lib\/..\/lib64 -L\/usr\/lib\/x86_64-linux-gnu -L\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/.. -L\/usr\/lib\/llvm-10\/bin\/..\/lib -L\/lib -L\/usr\/lib \/tmp\/test-593447.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/crtend.o \/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/crtn.o\r\n<\/code><\/pre>\n<p>\u8bf7\u6ce8\u610f\u6700\u540e\u4e00\u884c\u542f\u52a8\u4e86\u94fe\u63a5\u5668\u3002<br \/>\n\u60a8\u53ef\u4ee5\u770b\u5230\u94fe\u63a5\u7684\u662f-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc\uff0c\u800c\u4e0d\u662flibc++\uff0c\u800c\u662f\u4f7f\u7528\u4e86libstdc++\u3002<\/p>\n<h2>-stdlib=libc++<br \/>\n-stdlib=libc++ \u3092\u3064\u3051\u308b\u3068 libc++ \u3092\u4f7f\u3063\u3066\u304f\u308c\u308b\u3001\u306f\u305a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ clang++-10 -stdlib=libc++ test.cc\r\ntest.cc:1:10: fatal error: 'cstdio' file not found\r\n#include &lt;cstdio&gt;\r\n         ^~~~~~~~\r\n1 error generated.\r\n<\/code><\/pre>\n<p>\u304c\u3001\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u3069\u3046\u3084\u3089\u3001\u6a19\u6e96\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u3067\u306f libc++ \u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code># apt install -y libc++-10-dev\r\nReading package lists... Done\r\nBuilding dependency tree\r\nReading state information... Done\r\nThe following additional packages will be installed:\r\n  libc++1-10 libc++abi1-10\r\nSuggested packages:\r\n  clang\r\nThe following NEW packages will be installed:\r\n  libc++-10-dev libc++1-10 libc++abi1-10\r\n0 upgraded, 3 newly installed, 0 to remove and 9 not upgraded.\r\n<\/code><\/pre>\n<p>libc++abi1-10 \u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u5165\u3063\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u3092\u3084\u308a\u306a\u304a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ clang++-10 -stdlib=libc++ test.cc\r\n\/usr\/bin\/ld: cannot find -lc++abi\r\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\r\n<\/code><\/pre>\n<p>\u9519\u8bef\u5df2\u7ecf\u6539\u53d8\u4e86\u3002libc++abi \u65e0\u6cd5\u627e\u5230\u3002\u867d\u7136\u5df2\u7ecf\u5b89\u88c5\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ls -l \/usr\/lib\/x86_64-linux-gnu\/libc++*\r\nlrwxrwxrwx 1 root root 23 May  7 16:32 \/usr\/lib\/x86_64-linux-gnu\/libc++.a -&gt; ..\/llvm-10\/lib\/libc++.a\r\nlrwxrwxrwx 1 root root 24 May  7 16:32 \/usr\/lib\/x86_64-linux-gnu\/libc++.so -&gt; ..\/llvm-10\/lib\/libc++.so\r\nlrwxrwxrwx 1 root root 13 May  7 16:32 \/usr\/lib\/x86_64-linux-gnu\/libc++.so.1 -&gt; libc++.so.1.0\r\nlrwxrwxrwx 1 root root 28 May  7 16:32 \/usr\/lib\/x86_64-linux-gnu\/libc++.so.1.0 -&gt; ..\/llvm-10\/lib\/libc++.so.1.0\r\nlrwxrwxrwx 1 root root 16 May  7 16:32 \/usr\/lib\/x86_64-linux-gnu\/libc++abi.so.1 -&gt; libc++abi.so.1.0\r\nlrwxrwxrwx 1 root root 31 May  7 16:32 \/usr\/lib\/x86_64-linux-gnu\/libc++abi.so.1.0 -&gt; ..\/llvm-10\/lib\/libc++abi.so.1.0\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u7f3a\u5c11libc++abi.so\u6587\u4ef6\uff0c\u56e0\u6b64\u5c06\u5c1d\u8bd5\u521b\u5efa\u7b26\u53f7\u94fe\u63a5\u3002<\/p>\n<pre class=\"post-pre\"><code>$ cd usr\/lib\/x86_64-linux-gnu\r\n$ sudo ln -s libc++abi.so.1 libc++abi.so\r\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e86\u5417\uff1f<\/p>\n<pre class=\"post-pre\"><code>$ clang++-10 -stdlib=libc++ test.cc\r\n$ .\/a.out\r\nhello\r\n<\/code><\/pre>\n<p>\u6211\u4f1a\u52a0\u4e0a-v\u53c2\u6570\u6765\u67e5\u770b\u94fe\u63a5\u90e8\u5206\u3002<\/p>\n<pre class=\"post-pre\"><code>-lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc \r\n<\/code><\/pre>\n<p>\u54e6\uff0c\u786e\u5b9e\u770b\u8d77\u6765\u662f\u5728\u4f7f\u7528libc++\u800c\u4e0d\u662flibstdc++\u3002<\/p>\n<h2>&#8211; \u7f16\u8bd1\u5668\u8fd0\u884c\u65f6\u5e93\u7684\u9009\u9879\u662f rtlib=compiler-rt\u3002\u3057\u304b\u3057\u3001 compiler runtime library \u3068\u3057\u3066 LLVM \u306e compiler-rt \u306f\u4f7f\u308f\u308c\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u3002\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3053\u308c\u3082 LLVM \u306e\u3082\u306e\u3092\u4f7f\u3044\u305f\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ clang++-10 -v -stdlib=libc++ -rtlib=compiler-rt test.cc\r\n<\/code><\/pre>\n<p>\u3059\u308b\u3068\u78ba\u304b\u306b\u30ea\u30f3\u30af\u30aa\u30d7\u30b7\u30e7\u30f3\u304c<\/p>\n<pre class=\"post-pre\"><code>-lc++ -lm \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/lib\/linux\/libclang_rt.builtins-x86_64.a -lc \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/lib\/linux\/libclang_rt.builtins-x86_64.a \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/lib\/linux\/clang_rt.crtend-x86_64.o \r\n<\/code><\/pre>\n<p>\u306e\u3088\u3046\u306b\u5909\u308f\u308a\u3001 compiler-rt \u3092\u4f7f\u3063\u3066\u304f\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<br \/>\n\u3068\u3053\u308d\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ea\u30f3\u30af\u30a8\u30e9\u30fc\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>\/tmp\/test-2ede37.o: In function `main':\r\ntest.cc:(.text+0x59): undefined reference to `_Unwind_Resume'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_RaiseException'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_GetLanguageSpecificData'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_DeleteException'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_SetIP'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_GetRegionStart'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_SetGR'\r\n\/usr\/bin\/..\/lib\/gcc\/x86_64-linux-gnu\/7.5.0\/..\/..\/..\/x86_64-linux-gnu\/libc++abi.so: undefined reference to `_Unwind_GetIP'\r\n<\/code><\/pre>\n<h2>-unwindlib=libgcc\u3069\u3046\u3084\u3089\u3001unwind library (https:\/\/clang.llvm.org\/docs\/Toolchain.html#unwind-library \u306b\u8aac\u660e\u304c\u3042\u308b ) \u304c\u30ea\u30f3\u30af\u3067\u304d\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u3002\u78ba\u304b\u306b\u30ea\u30f3\u30af\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u3082\u305d\u308c\u3063\u307d\u3044\u6307\u5b9a\u304c\u306a\u3044\u3002<\/p>\n<p>\u4e0a\u8a18\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3082\u6307\u5b9a\u306e\u65b9\u6cd5\u306e\u8aac\u660e\u304c\u306a\u304f\u3001\u3053\u3053\u3067\u30cf\u30de\u3063\u305f\u306e\u3067 LLVM \u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>https:\/\/github.com\/llvm\/llvm-project\/blob\/17e13da29de48e10fa4ae50831e781d9c44edde9\/clang\/lib\/Driver\/ToolChain.cpp#L791-L816<br \/>\nhttps:\/\/github.com\/llvm\/llvm-project\/blob\/2da89df4e8d240160d5f265ecac4b0c6a0705d65\/clang\/lib\/Driver\/ToolChains\/CommonArgs.cpp#L1218-L1234<\/p>\n<p>\u3069\u3046\u3084\u3089\u3001 -unwindlib \u3068\u3044\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\u306b libgcc \u3068\u304b libunwind \u3092\u6307\u5b9a\u3059\u308c\u3070\u3088\u3044\u3088\u3046\u3067\u3059\u3002<br \/>\n(clang++ &#8211;help \u3092\u898b\u3066\u307f\u305f\u3089\u3042\u3063\u3055\u308a\u3068\u3057\u305f\u8aac\u660e\u304c\u3042\u308a\u307e\u3057\u305f: -unwindlib= Unwind library to use)<\/p>\n<p>\u65e2\u7136\u6709\u673a\u4f1a\uff0c\u6211\u60f3\u8981\u4f7f\u7528LLVM\u7684libunwind\uff0c\u4f46\u662f\u5728\u770b\u8d77\u6765LLVM\u7684apt\u5b58\u50a8\u5e93\u4f3c\u4e4e\u6ca1\u6709\u63d0\u4f9b\u8fd9\u4e2a\u3002<br \/>\n\u65e0\u5948\u7684\u662f\uff0c\u6211\u51b3\u5b9a\u5728\u8fd9\u91cc\u4f7f\u7528libgcc_s\uff08GNU\uff09\u66ff\u4ee3\u3002<\/p>\n<pre class=\"post-pre\"><code>$ clang++-10 -stdlib=libc++ -rtlib=compiler-rt -unwindlib=libgcc test.cc\r\n$ .\/a.out\r\nhello\r\n<\/code><\/pre>\n<p>\u3088\u3046\u3084\u304f\u901a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u30ea\u30f3\u30af\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3053\u3093\u306a\u611f\u3058 (\u4e00\u90e8\u629c\u7c8b)\u3002 -lgcc_s \u304c\u5897\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>-lc++ -lm \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/lib\/linux\/libclang_rt.builtins-x86_64.a -lgcc_s -lc \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/lib\/linux\/libclang_rt.builtins-x86_64.a -lgcc_s \/usr\/lib\/llvm-10\/lib\/clang\/10.0.1\/lib\/linux\/clang_rt.crtend-x86_64.o \r\n<\/code><\/pre>\n<p>\u628a\u6240\u6709\u90fd\u653e\u8fdb\u53bb\u5427\u3002<\/p>\n<h2>\u603b\u7ed3<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">(\u5c11\u306a\u304f\u3068\u3082 LLVM \u516c\u5f0f\u624b\u9806\u3067 Ubuntu \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f) clang++ \u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f libc++ \u3067\u306f\u306a\u304f libstdc++ \u3092\u4f7f\u3046<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">runtime library \u306e\u5207\u308a\u66ff\u3048\u306f -stdlib \/ -rtlib \/ -unwindlib \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u884c\u3046<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">LLVM \u516c\u5f0f\u624b\u9806\u3067 Ubuntu \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3060\u3051\u3060\u3068 libc++ \u3092\u4f7f\u3046\u306e\u306f\u610f\u5916\u306b\u3066\u3053\u305a\u308a\u307e\u3059<\/ul>\n<h3>\u5728Ubuntu\u4e0a\u4f7f\u7528clang\u548clibc++\u7684\u6b65\u9aa4<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">LLVM \u306e\u6a19\u6e96\u306e\u624b\u9806 \u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">apt install -y libc++-10-dev<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">cd usr\/lib\/x86_64-linux-gnu &amp;&amp; sudo ln -s libc++abi.so.1 libc++abi.so<\/ul>\n<p>\u3068\u3057\u305f\u3046\u3048\u3067\u3001<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">libc++ \u3060\u3051\u3092\u4f7f\u3046: -stdlib=libc++<\/ul>\n<\/li>\n<\/ul>\n<p>compiler-rt \u3082\u4f7f\u3046: -stdlib=libc++ -rtlib=compiler-rt -unwindlib=libgcc<\/p>\n<p>LLVM libunwind \u3082\u4f7f\u3046: (\u3053\u308c\u306f\u4eca\u56de\u8a66\u3057\u3066\u306a\u3044)<\/p>\n<p>\u6211\u5c06\u8fd9\u6837\u5047\u8bbe\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4ec0\u4e48\uff1f\u5728\u4f7f\u7528Ubuntu\u4e0a\u7684clang\u7f16\u8bd1\u5668\u8fdb\u884cC++\u5f00\u53d1\u65f6\uff0c\u6211\u4eec\u5e38\u5e38\u4f7f\u7528\u7684\u662f\uff08GNU\u5de5\u5177\u94fe\u7684\uff09libst [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[227],"class_list":["post-28059","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++ - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u5173\u4e8e\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-ubuntu-\u4e0a\u4f7f\u7528-clang-libc\u3002-4\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\" \/>\n<meta property=\"og:description\" content=\"\u5173\u4e8e\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-ubuntu-\u4e0a\u4f7f\u7528-clang-libc\u3002-4\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-09T07:33:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-11T22:08:02+00:00\" \/>\n<meta name=\"author\" content=\"\u65b0, \u97f5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u65b0, \u97f5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/\",\"name\":\"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++ - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-11-09T07:33:06+00:00\",\"dateModified\":\"2025-08-11T22:08:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9\"},\"description\":\"\u5173\u4e8e\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\u7684\u6280\u672f\u6587\u7ae0\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9\",\"name\":\"\u65b0, \u97f5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g\",\"caption\":\"\u65b0, \u97f5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunxin\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++ - Blog - Silicon Cloud","description":"\u5173\u4e8e\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\u7684\u6280\u672f\u6587\u7ae0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-ubuntu-\u4e0a\u4f7f\u7528-clang-libc\u3002-4\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++","og_description":"\u5173\u4e8e\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\u7684\u6280\u672f\u6587\u7ae0","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728-ubuntu-\u4e0a\u4f7f\u7528-clang-libc\u3002-4\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-11-09T07:33:06+00:00","article_modified_time":"2025-08-11T22:08:02+00:00","author":"\u65b0, \u97f5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u65b0, \u97f5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/","name":"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++ - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-11-09T07:33:06+00:00","dateModified":"2025-08-11T22:08:02+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9"},"description":"\u5173\u4e8e\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++\u7684\u6280\u672f\u6587\u7ae0","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5728 Ubuntu \u4e0a\u4f7f\u7528 clang + libc++"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9","name":"\u65b0, \u97f5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g","caption":"\u65b0, \u97f5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunxin\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8-ubuntu-%e4%b8%8a%e4%bd%bf%e7%94%a8-clang-libc%e3%80%82-4\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/28059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=28059"}],"version-history":[{"count":3,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/28059\/revisions"}],"predecessor-version":[{"id":111257,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/28059\/revisions\/111257"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=28059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=28059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=28059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}