undefined reference to `__gxx_personality_sj0`(对 `__gxx_personality_sj0` 的未定义引用)
问题描述
使用 gcc 4.6 尝试执行此代码时:
With gcc 4.6 when trying to execute this code:
#include <iostream>
using namespace std;
#include <bitset>
int main()
{
//Int<> a;
long long min = std::numeric_limits<int>::min();
unsigned long long max = std::numeric_limits<int>::max();
cout << "min: " << min << '
';
cout << "max: " << max << '
';
cout << (min <= max);
std::bitset<64> minimal(min);
cout << "minimal: " << minimal;
return 0;
}
我收到以下错误:
1.对__gxx_personality_sj
的未定义引用2.对_Unwind_SjLj_Register
的未定义引用3.对_Unwind_SjLj_Unregister
的未定义引用4.对_Unwind_SjLj_Resume
到底是怎么回事?!
推荐答案
这些函数是 GCC 的 C++ 异常处理支持的一部分.GCC 支持两种异常处理,一种基于调用 setjmp 和 longjmp(sjlj 异常处理),另一种基于 DWARF 调试信息格式(DW2 异常处理).
These functions are part of the C++ exception handling support for GCC. GCC supports two kinds of exception handling, one which is based on calls to setjmp and longjmp (sjlj exception handling), and another which is based on the DWARF debugging info format (DW2 exception handling).
如果您尝试在单个可执行文件中混合使用不同异常处理实现编译的对象,则会发生这些类型的链接器错误.您似乎使用的是 DW2 GCC,但您尝试使用的某些库是使用 sjlj 版本的 GCC 编译的,从而导致了这些错误.
These sorts of linker errors will occur is you try to mix objects that were compiled with different exception handling implementations in a single executable. It appears that you are using a DW2 GCC, but some library that you are attempting to use was compiled with a sjlj version of GCC, leading to these errors.
简而言之,这类问题是由不同编译器之间的 ABI 不兼容引起的,因此当您混合使用不同编译器编译的库或使用同一编译器的不兼容版本时,就会发生此类问题.
The short answer is that these sorts of problems are caused by ABI incompatibilities between different compilers, and so occur when you mix libraries compiled with different compilers, or use incompatible versions of the same compiler.
这篇关于对 `__gxx_personality_sj0` 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:对 `__gxx_personality_sj0` 的未定义引用


基础教程推荐
- 这个宏可以转换成函数吗? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01