glog-0.6.0 undefined reference to `typeinfo for testing::Test‘

在尝试编译和链接C++测试程序时,遇到了与GoogleTest(gtest)相关的链接错误,具体表现为undefinedreferenceto`typeinfofortesting::Test。这通常意味着gtest库没有正确地链接到目标可执行文件中。解决方案可能包括检查gtest是否已正确安装,以及CMake配置中的WITH_GTEST选项是否开启。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

error

/usr/bin/ld: CMakeFiles/utilities_unittest.dir/src/utilities_unittest.cc.o:(.data.rel.ro._ZTI41utilities_InitGoogleLoggingDeathTest_Test[_ZTI41utilities_InitGoogleLoggingDeathTest_Test]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: CMakeFiles/utilities_unittest.dir/src/utilities_unittest.cc.o:(.data.rel.ro._ZTI40utilities_sync_val_compare_and_swap_Test[_ZTI40utilities_sync_val_compare_and_swap_Test]+0x10): undefined reference to `typeinfo for testing::Test'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/utilities_unittest.dir/build.make:101: utilities_unittest] Error 1
make[1]: *** [CMakeFiles/Makefile2:1101: CMakeFiles/utilities_unittest.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: CMakeFiles/demangle_unittest.dir/src/demangle_unittest.cc.o:(.data.rel.ro._ZTI22Demangle_FromFile_Test[_ZTI22Demangle_FromFile_Test]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: CMakeFiles/demangle_unittest.dir/src/demangle_unittest.cc.o:(.data.rel.ro._ZTI20Demangle_Clones_Test[_ZTI20Demangle_Clones_Test]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: CMakeFiles/demangle_unittest.dir/src/demangle_unittest.cc.o:(.data.rel.ro._ZTI25Demangle_CornerCases_Test[_ZTI25Demangle_CornerCases_Test]+0x10): undefined reference to `typeinfo for testing::Test'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/demangle_unittest.dir/build.make:101: demangle_unittest] Error 1
make[1]: *** [CMakeFiles/Makefile2:1049: CMakeFiles/demangle_unittest.dir/all] Error 2
/usr/bin/ld: CMakeFiles/symbolize_unittest.dir/src/symbolize_unittest.cc.o:(.data.rel.ro._ZTI54Symbolize_SymbolizeWithDemanglingStackConsumption_Test[_ZTI54Symbolize_SymbolizeWithDemanglingStackConsumption_Test]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: CMakeFiles/symbolize_unittest.dir/src/symbolize_unittest.cc.o:(.data.rel.ro._ZTI40Symbolize_SymbolizeStackConsumption_Test[_ZTI40Symbolize_SymbolizeStackConsumption_Test]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: CMakeFiles/symbolize_unittest.dir/src/symbolize_unittest.cc.o:(.data.rel.ro._ZTI38Symbolize_SymbolizeWithDemangling_Test[_ZTI38Symbolize_SymbolizeWithDemangling_Test]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: CMakeFiles/symbolize_unittest.dir/src/symbolize_unittest.cc.o:(.data.rel.ro._ZTI24Symbolize_Symbolize_Test[_ZTI24Symbolize_Symbolize_Test]+0x10): undefined reference to `typeinfo for testing::Test'

option (WITH_GTEST "Use Google Test" OFF)

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值