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’的引用
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- c++ STL设置差异 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
