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中添加以下函數spa

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

結果仍是一直報錯,而後添加各類預約宏也解決不了。.net

後來查看<boost\throw_exception.hpp>發現,應該使用namespace boostcode

namespace boost
{
#ifdef BOOST_NO_EXCEPTIONS

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

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

在報錯的那個cpp中添加以下函數後解決blog

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

最後,感謝http://blog.csdn.net/is2120/article/details/6385304io

相關文章
相關標籤/搜索