error Boost.Log: RTTI is required by the library 问题解决
问题描述
今天在VS项目中使用Boost.log时遇到了这个问题
error Boost.Log: RTTI is required by the library
这里的话通过一步步的debug找到,boost/config/compiler/visualc.hpp文件中,存在着以下的代码
#if !defined(_CPPRTTI) && !defined(BOOST_NO_RTTI)
# define BOOST_NO_RTTI
#endif
这一部分会检测系统中是否开启了_CPPRTTI,如果没有的话则定义一个BOOST_NO_RTTI,导致后面在boost/log/detail/config.hpp文件中
// The library requires dynamic_cast in a few places
#if defined(BOOST_NO_RTTI)
# error Boost.Log: RTTI is required by the library
#endif
出现了改编译错误
问题解决
通过搜索发现,需要开启系统编译的/GR选项,具体开启方式为(VS):
项目属性 -> C/C++ -> 语言 -> 启用运行时类型信息"是(/GR)"
问题解决