Undefined link to `__cxa_thread_atexit @@ CXXABI` when compiling with` lib ++` on linux

I am trying to compile my projects on Arch Linux x64 using lib ++ , lib ++ abi and clang ++ 3.6. 0 .

Projects compile correctly, but are not related to the following error:

error: CMakeFiles / main.cpp.o: undefined reference to the symbol '__cxa_thread_atexit @@ CXXABI_1.3.7'

/ usr / lib / libstdc ++. so.6: -1: error: error adding characters: missing DSO from the command line

I compile and link using the flags -stdlib=libc++ -lc++abi .

Is there any additional library I should link? Am I missing a flag?

+5
source share
1 answer

Either link to -lsupc++ , or a small wrapper function (perhaps the best way for libc++ ) to implement glibc:

 extern "C" int __cxa_thread_atexit(void (*func)(), void *obj, void *dso_symbol) { int __cxa_thread_atexit_impl(void (*)(), void *, void *); return __cxa_thread_atexit_impl(func, obj, dso_symbol); } 

It might be worth mentioning that this only works with glibc> = 2.18.

+7
source

Source: https://habr.com/ru/post/1216365/


All Articles