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