简体   繁体   English

Boost无法解析的外部符号

[英]Unresolved external symbols with Boost

I am trying to compile the Boost.Regex program from the Getting Started Guide , but even though I am linking the required libraries, I am getting some unresolved external symbols: 我正在尝试从《 入门指南》中编译Boost.Regex程序,但是即使我链接了所需的库,也遇到了一些无法解析的外部符号:

 1>------ Build started: Project: Project1, Configuration: Debug Win32 ------ 1> main.cpp 1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::re_detail_106100::raw_storage::resize(unsigned int)" (?resize@raw_storage@re_detail_106100@boost@@QAEXI@Z) referenced in function "public: void * __thiscall boost::re_detail_106100::raw_storage::extend(unsigned int)" (?extend@raw_storage@re_detail_106100@boost@@QAEPAXI@Z) 1>main.obj : error LNK2019: unresolved external symbol "public: void * __thiscall boost::re_detail_106100::raw_storage::insert(unsigned int,unsigned int)" (?insert@raw_storage@re_detail_106100@boost@@QAEPAXII@Z) referenced in function "public: struct boost::re_detail_106100::re_syntax_base * __thiscall boost::re_detail_106100::basic_regex_creator<char,struct boost::regex_traits<char,class boost::cpp_regex_traits<char> > >::insert_state(int,enum boost::re_detail_106100::syntax_element_type,unsigned int)" (?insert_state@?$basic_regex_creator@DU?$regex_traits@DV?$cpp_regex_traits@D@boost@@@boost@@@re_detail_106100@boost@@QAEPAUre_syntax_base@23@HW4syntax_element_type@23@I@Z) 1>C:\\Users\\unknown\\Documents\\Visual Studio 2015\\Projects\\Project1\\Debug\\Project1.exe : fatal error LNK1120: 2 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

Here is the code (taken from here ): 这是代码(从此处获取 ):

#include <boost/regex.hpp>
#include <iostream>
#include <string>

int main()
{
    std::string line;
    boost::regex pat("^Subject: (Re: |Aw: )*(.*)");

    while (std::cin)
    {
        std::getline(std::cin, line);
        boost::smatch matches;
        if (boost::regex_match(line, matches, pat))
            std::cout << matches[2] << std::endl;
    }
}

Some information: 一些信息:

  • This happens under Debug and Release 这发生在调试和发布下
  • I can't build the project under x64, because the libraries are x86 我无法在x64下构建项目,因为库是x86
  • I built the static library using bootstrap , then b2 我先使用bootstrap构建静态库,然后使用b2
  • I included libboost_regex-vc140-mt-1_61.lib ( libboost_regex-vc140-mt-gd-1_61.lib for Debug) 我包括了libboost_regex-vc140-mt-1_61.lib (用于调试的libboost_regex-vc140-mt-gd-1_61.lib
  • Not using Unicode character set (in Visual Studio project properties) 不使用Unicode字符集(在Visual Studio项目属性中)
  • I am using Visual Studio 2015 我正在使用Visual Studio 2015
  • I am using Boost 1.61 我正在使用Boost 1.61
  • This happens for every Boost code that requires a library 对于需要库的每个 Boost代码都会发生这种情况
  • This obviously doesn't happen for header only Boost libraries 对于仅标头的Boost库,这显然不会发生

Any ideas? 有任何想法吗?

此链接http://lists.boost.org/boost-users/2010/04/57957.php建议在构建boost库和您的项目之间,编译器标志有所不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM