链接错误“未定义的引用”__gxx_personality_v0“和g ++ [英] Link error "undefined reference to `__gxx_personality_v0'" and g++
本文介绍了链接错误“未定义的引用”__gxx_personality_v0“和g ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对以下程序有问题。
// 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
并获取:
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 ++
仍然出现错误尝试使用:
If g++
still gives error Try using:
g++ file.c -lstdc++
确保 -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 ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文