How can I statically link libc++ under linux?

So I’m building a plugin, which links libc++ and is compiled with clang.

when I load that plugin, it always complains undefined symbol “_ZNKSt3__119__shared_weak_count13__get_deleterERKSt9type_info”

I’m attempting to resolve it by statically link to libc++.

if I google online, most answers say adding -static, but it doesn’t work at all. I found this discussion, ⚙ D96070 [clang] [driver] Enable static linking to libc++ , which got me confused. is this function working at all?

I’m currently trying everything I can think of"


they don’t work at all, after building, if I check symbols using nm, I can still see the symbol is missing.

what’s the right way to do it?

right now, the only way to get the plugin loaded is doing


and even with the above build flags, if I check the so file with objdump -x:

Dynamic Section:

it still loads libstdc++

1 Like