无法解析的外部符号 “void __cdecl boost::throw_exception(class std::exception const &)”解决方法

本文介绍了如何在使用Boost库时,由于默认禁用了异常处理(BOOST_NO_EXCEPTIONS),需用户自定义throw_exception函数。同时,提到在项目属性中添加/EHsc编译标志来启用异常安全代码。

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

第一种1.boost库默认定义了BOOST_NO_EXCEPTIONS宏,需要用户自定义throw_exception函数,在报错的那个cpp中重新定义throw_exception函数

void throw_exception(std::exception const & e) 

{ return; }

第二种2.在项目属性中添加/EHsc

set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}")

或者

set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/EHsc")

boost::property_tree::read_xml(strTmp, pt);加入这个严重性 代码 说明 项目 文件 行 禁止显示状态 详细信息 错误 LNK2019 无法解析外部符号 "void __cdecl boost::throw_exception(class std::exception const &,struct boost::source_location const &)" (?throw_exception@boost@@YAXAEBVexception@std@@AEBUsource_location@1@@Z),函数 "void __cdecl boost::property_tree::xml_parser::read_xml<class boost::property_tree::basic_ptree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::property_tree::basic_ptree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,int,class std::locale const &)" (??$read_xml@V?$basic_ptree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@property_tree@boost@@@xml_parser@property_tree@boost@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAV?$basic_ptree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@12@HAEBVlocale@4@@Z) 中引用了该符号 D:\SAMA\sama\build\msvc-Debug\sama D:\SAMA\sama\build\msvc-Debug\copidfunction.cpp.obj 1 错误 LNK1120 1 个无法解析外部命令 D:\SAMA\sama\build\msvc-Debug\sama D:\SAMA\sama\out\MSVC-Debug\sama.exe 1
最新发布
03-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值