undefined reference to `__gxx_personality_v0'

undefined reference to `__gxx_personality_v0'


刚刚在做一个实验,编译的时候出了一点问题,下面附上代码:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static void my_exit1(void);
static void my_exit2(void);

int
main(void)
{
	if (atexit(my_exit2) != 0)
		printf("can not register my_exit2\n");
	
	if (atexit(my_exit1) != 0)
		printf("can not register my_exit1\n");
	if (atexit(my_exit1) != 0)
		printf("can not register my_exit1'=\n");
	
	printf("main is done\n");
	return(0);
}

static void
my_exit1(void)
{
	printf("first exit handler\n");
}

static void
my_exit2(void)
{
	printf("second exit handler\n");
}

检查了很多遍发现没啥问题呀,但是用以下编译语句时报错:

gcc -o main main.C

报错信息如下:

/tmp/ccAi9DGt.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld 返回 1

后来查找资料后得知,这里我用的是gcc来编译的,源文件却是.C(实际内容是c),实际.C代表着是c++的源文件,额,就报错了。

解决办法(改成c文件后缀即可):

mv main.C main.c
gcc -o main main.c

编译通过。

网上还有别的类似的编译错误,这里留个mark,以后发现类似的再来这里总结下~
/usr/bin/ld: summinfo.cpp:(.text._ZN11xlslib_core10hpsf_doc_t7addItemEty[_ZN11xlslib_core10hpsf_doc_t7addItemEty]+0x59): undefined reference to `operator delete(void*)' /usr/bin/ld: ../../src/.libs/libxls.a(summinfo.o):(.rodata._ZTIN11xlslib_core12CSummaryInfoE[_ZTIN11xlslib_core12CSummaryInfoE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' /usr/bin/ld: ../../src/.libs/libxls.a(summinfo.o):(.eh_frame+0x13): undefined reference to `__gxx_personality_v0' /usr/bin/ld: ../../src/.libs/libxls.a(colinfo.o): in function `xlslib_core::CColInfo::~CColInfo()': colinfo.cpp:(.text+0x192): undefined reference to `operator delete(void*)' /usr/bin/ld: ../../src/.libs/libxls.a(colinfo.o): in function `__static_initialization_and_destruction_0(int, int)': colinfo.cpp:(.text+0x1bf): undefined reference to `std::ios_base::Init::Init()' /usr/bin/ld: colinfo.cpp:(.text+0x1ce): undefined reference to `std::ios_base::Init::~Init()' /usr/bin/ld: ../../src/.libs/libxls.a(colinfo.o):(.rodata._ZTIN11xlslib_core8CColInfoE[_ZTIN11xlslib_core8CColInfoE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info' /usr/bin/ld: ../../src/.libs/libxls.a(colinfo.o):(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0' /usr/bin/ld: ../../src/.libs/libxls.a(continue.o): in function `xlslib_core::CContinue::~CContinue()': continue.cpp:(.text+0x116): undefined reference to `operator delete(void*)' /usr/bin/ld: ../../src/.libs/libxls.a(continue.o): in function `__static_initialization_and_destruction_0(int, int)': continue.cpp:(.text+0x143): undefined reference to `std::ios_base::Init::Init()' /usr/bin/ld: continue.cpp:(.text+0x152): undefined reference to `std::ios_base::Init::~Init()' /usr/bin/ld: ../../src/.libs/libxls.a(continue.o):(.rodata._ZTIN11xlslib_core9CContinueE[_ZTIN11xlslib_core9CContinueE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info' /usr/bin/ld: ../../src/.libs/libxls.a(continue.o):(.eh_frame+0x6b): undefined reference to `__gxx_personality_v0' collect2: error: ld returned 1 exit status make[2]: *** [Makefile:590:testC] 错误 1 make[2]: 离开目录“/home/zhu/桌面/xlslib/xlslib/targets/test” make[1]: *** [Makefile:322:all-recursive] 错误 1 make[1]: 离开目录“/home/zhu/桌面/xlslib/xlslib/targets” make: *** [Makefile:418:all-recursive] 错误 1 make xlslib出现的
03-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值