错误libc++.so:未定义对"_Unwind_GetRegionStart"的引用
Error libc++.so: undefined reference to `_Unwind_GetRegionStart'
我正在尝试用clang++-4.0
编译我的第一个C++胚胎
我的代码:
//main.cpp
#include <iostream>
// this line is to deal with the link error:
// "undefined reference to symbol '__cxa_thread_atexit@@CXXABI..."
// cf. http://stackoverflow.com/q/29322666/356440
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);
}
int main ()
{
return 0;
}
我用clang++-4.0
编译,并以这种方式与ld
链接:
clang++-4.0 -c main.cpp -o main.o
ld -o test main.o -lc++ -lc++abi -lc
就好像我错过了与另一个库的链接,但我不知道是哪个或一个。
你看到有什么问题或缺失吗?我想我错过了一些初学者的东西,以便在 linux 上用clang++
做 c++ 的东西。
编译错误:
ld:警告:找不到条目符号_start;默认为 0000000000400380 main.o:在函数
__cxx_global_var_init': main.cpp:(.text.startup+0x13): undefined reference to
std::ios_base::Init::Init()' main.cpp:(.text.startup+0x19): undefined 参考std::ios_base::Init::~Init()' main.cpp:(.text.startup+0x2d): undefined reference to
__dso_handle' usr/lib/x86_64-linux-gnu/libc++.so:未定义的引用_Unwind_GetRegionStart' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_RaiseException' usr/lib/x86_64-linux-gnu/libc++.so:未定义的引用_Unwind_SetIP' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_GetLanguageSpecificData' usr/lib/x86_64-linux-gnu/libc++.so:未定义的引用_Unwind_Resume' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_GetIP'//usr/lib/x86_64-linux-gnu/libc++.so: 对_Unwind_SetGR' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_DeleteException的未定义引用
不应将C++应用程序与ld
链接。与C++编译器可执行文件的链接,因为它链接到所有必要的库中:
clang++-4.0 -c main.cpp -o main.o
clang++-4.0 -o test main.o
- 将对象数组的引用传递给函数
- 什么时候在C++中返回常量引用是个好主意
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 何时在引用或唯一指针上使用移动语义
- 如何在c++中使用引用实现类似python的行为
- 编译C++时未定义的引用
- Ctypes wstring通过引用传递
- c++r值引用应用于函数指针
- 理解c++中的引用
- C++取消引用指针.为什么会发生变化
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 强制转换为引用类型
- 引用一个已擦除类型(void*)的指针
- 向量元素的引用地址与它所指向的向量元素的地址不同.为什么
- 具有默认值的引用获取函数
- 如何使用基类指针引用派生类成员
- 使用取消引用的指针的多态性会产生意外的结果.为什么?
- 如何引用基类的派生类?