使用 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` 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!