unresolved external symbol boost::throw_exception

使用boost库,VS生成的时候一直报错,
error LNK2019: 无法解析的外部符号 "void __cdecl boost::throw_exception(class std::exception const &)"

搜索网上资料得知,可能是使用的boost库默认定义了BOOST_NO_EXCEPTIONS宏,需要用户自定义throw_exception函数,在报错的那个cpp中添加如下函数

void throw_exception(std::exception const & e) // user defined
{
	return;
}

结果还是一直报错,然后添加各种预定宏也解决不了。

后来查看<boost\throw_exception.hpp>发现,应该使用namespace boost

namespace boost
{
#ifdef BOOST_NO_EXCEPTIONS

void throw_exception( std::exception const & e ); // user defined

#else
  //省略若干
#endif
} // namespace boost

在报错的那个cpp中添加如下函数后解决

namespace boost
{
	void throw_exception(std::exception const & e) // user defined
	{
		return;
	}
}

最后,感谢http://blog.csdn.net/is2120/article/details/6385304

posted on 2018-03-13 20:45  woswod  阅读(669)  评论(0编辑  收藏  举报

导航