Visual 2015链接错误与提升日志

时间:2016-08-30 11:58:11

标签: c++ visual-studio-2015 boost-log

我正在从VS'2008 + Boost 1.144到VS'2015 + Boost 1.61进行源代码迁移,我收到以下链接错误

... error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl boost::log::v2_mt_nt5::attributes::named_scope::push_scope(struct boost::log::v2_mt_nt5::attributes::named_scope_entry const &)" (__imp_?push_scope@named_scope@attributes@v2_mt_nt5@log@boost@@SAXABUnamed_scope_entry@2345@@Z) referenced in function "public: __thiscall boost::log::v2_mt_nt5::attributes::named_scope::sentry::sentry(class boost::log::v2_mt_nt5::basic_string_literal<char,struct std::char_traits<char> > const &,class boost::log::v2_mt_nt5::basic_string_literal<char,struct std::char_traits<char> > const &,unsigned int,enum boost::log::v2_mt_nt5::attributes::named_scope_entry::scope_name_type)" (??0sentry@named_scope@attributes@v2_mt_nt5@log@boost@@QAE@ABV?$basic_string_literal@DU?$char_traits@D@std@@@345@0IW4scope_name_type@named_scope_entry@2345@@Z)
... : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl boost::log::v2_mt_nt5::attributes::named_scope::pop_scope(void)" (__imp_?pop_scope@named_scope@attributes@v2_mt_nt5@log@boost@@SAXXZ) referenced in function "public: __thiscall boost::log::v2_mt_nt5::attributes::named_scope::sentry::~sentry(void)" (??1sentry@named_scope@attributes@v2_mt_nt5@log@boost@@QAE@XZ)

构建我使用的提升 :

bootstrap.bat
b2 --build-dir=build-directory toolset=msvc-14.0 --build-type=complete define=BOOST_LOG_NO_COMPILER_TLS stage

在源代码中,我使用了BOOST_LOG_DYN_LINK。似乎我正在使用的所有其他提升库都被正确找到并链接但不是提升日志而只有那两个函数。

我注意到在boost/log/attributes/named_scoped.hpp中,这两个函数被定义为static member类的named_scope(见下文)。我想知道是否可能是这种联系问题的原因?因为我不确定是否可以从dll导出/加载静态函数!

 /*!
     * The method pushes the scope to the back of the current thread's scope list
     *
     * \b Throws: Nothing.
     */
    static void push_scope(scope_entry const& entry) BOOST_NOEXCEPT;
    /*!
     * The method pops the last pushed scope from the current thread's scope list
     *
     * \b Throws: Nothing.
     */
    static void pop_scope() BOOST_NOEXCEPT;

欢迎任何解决这个问题的想法或建议。

1 个答案:

答案 0 :(得分:1)

我怀疑您的代码和Boost.Log之间的目标Windows API版本不匹配。请参阅this回答。