Link error quot;undefined reference to `__gxx_personality_v0#39;quot; and g++(链接错误“未定义对‘__gxx_personality_v0’的引用和 g++)
问题描述
可能重复:
链接上的未定义符号___gxx_personality_v0
我对以下程序有疑问.
// fkt.cpp
#include "fkt.h"
int add2(int a, int b)
{
return a+b;
}
还有标题:
// fkt.h
int add2(int a, int b);
现在我编译这个:
g++ -c fkt.cpp
现在我运行 nm
并得到:
Now I run nm
and get:
00000000 T _Z6add2ii
U __gxx_personality_v0
当我想在任何地方使用该功能时:
When I want to use the function anywhere I get:
(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
我该如何解决这个问题?(我正在使用 Ubuntu Linux.)
How can I solve this problem? (I'm using Ubuntu Linux.)
推荐答案
如果 g++
仍然报错 Try using:
If g++
still gives error Try using:
g++ file.c -lstdc++
看这篇文章:__gxx_personality_v0 是干什么用的?
确保 -lstdc++
位于命令的末尾.如果将它放在开头(即 file.c 之前),仍然会出现同样的错误.
Make sure -lstdc++
is at the end of the command. If you place it at the beginning (i.e. before file.c), you still can get this same error.
这篇关于链接错误“未定义对‘__gxx_personality_v0’的引用"和 g++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:链接错误“未定义对‘__gxx_personality_v0’的引用


- 哪个更快:if (bool) 或 if(int)? 2022-01-01
- 从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值 2021-01-01
- 将函数的返回值分配给引用 C++? 2022-01-01
- 如何提取 __VA_ARGS__? 2022-01-01
- XML Schema 到 C++ 类 2022-01-01
- GDB 不显示函数名 2022-01-01
- 将 hdc 内容复制到位图 2022-09-04
- OpenGL 对象的 RAII 包装器 2021-01-01
- DoEvents 等效于 C++? 2021-01-01
- 使用 __stdcall & 调用 DLLVS2013 中的 GetProcAddress() 2021-01-01