对‘__gxx_personality_v0’未定义的引用 collect2: 错误: ld 返回 1

在linux下使用vim编译C++程序,如果使用gcc命令进行编译,则有可能出现此错误:

hugo@hugo-HP:~/codes$ gcc -o codes TelNumRepeat.o
TelNumRepeat.o:(.eh_frame+0x4b):对‘__gxx_personality_v0’未定义的引用
collect2: 错误: ld 返回 1


原因就是使用gcc无法连接到c++库,所以会出现错误。

解决方法就是使用g++命令,g++命令可以连接到c++库。

hugo@hugo-HP:~/codes$ g++ -o codes TelNumRepeat.o
hugo@hugo-HP:~/codes$ ls
codes  TelNumRepeat.cpp  TelNumRepeat.o


原文地址:https://www.cnblogs.com/xinyuyuanm/p/2998681.html