在Linux上使用`libc ++`进行编译时,对`__cxa_thread_atexit @@ CXXABI`的未定义引用 [英] Undefined reference to `__cxa_thread_atexit@@CXXABI` when compiling with `libc++` on linux

查看:668
本文介绍了在Linux上使用`libc ++`进行编译时,对`__cxa_thread_atexit @@ CXXABI`的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 libc ++ libc ++ abi clang ++ 3.6在 Arch Linux x64 上编译项目. 0 .

I'm trying to compile my projects on Arch Linux x64 using libc++, libc++abi and clang++ 3.6.0.

项目可以正确编译,但无法链接并出现以下错误:

The projects compile properly, but fail to link with the following error:

错误:CMakeFiles/main.cpp.o:对符号'__cxa_thread_atexit @@ CXXABI_1.3.7'的未定义引用

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

/usr/lib/libstdc ++.so.6:-1:错误:添加符号错误:命令行缺少DSO

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

我正在使用-stdlib=libc++ -lc++abi标志进行编译和链接.

I'm compiling and linking using the -stdlib=libc++ -lc++abi flags.

我应该链接其他库吗?我想念国旗吗?

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

推荐答案

要么与-lsupc++链接,要么提供一个小的包装函数 (可能是libc++的更好方法)用于glibc实现:

Either link with -lsupc++ or provide a small wrapper function (probably the better way for libc++) for the glibc implementation:

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);
}

也许值得一提的是,这仅适用于glibc> = 2.18.

It may be worth to mention that this only works with glibc >= 2.18.

这篇关于在Linux上使用`libc ++`进行编译时,对`__cxa_thread_atexit @@ CXXABI`的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆