0

我将 boost 1.61.0 与 cl 19 (visual studio 2015) 一起使用。我使用命令行bootstrap.\b2. 这使得 stage 目录带有一些 vc14 前缀库。

但是当我尝试编译开始正则表达式程序时

#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;
    }
}

使用此命令行编译器设置:

cl main.cpp -I %BOOST_ROOT% -L %BOOST_LIB_14% /EHsc

我收到此错误:

Link:: fatal error LNK1181: cannot open input file 'C:\local\boost_1_61_0\stage\lib.obj

我的尝试有什么问题?

编辑:我将命令行编译更改为:

cl main.cpp /I %BOOST_ROOT% /link /LIBPATH:%BOOST_LIB_14% /EHsc

现在,我收到此错误:

LINK: fatal error LNK1104: cannot open file 'libbosst_regex-vc140-mt-s-1_61.lib'
4

1 回答 1

0

我找到了解决方案。

bootstrap我已经用和.\b2命令构建了 boost 库。它仅构建mt(多线程)和gd(调试)库。

对于我尝试过的静态链接 ( s) 库.\b2 runtime-link=static和那个 buit 'libbosst_regex-vc140-mt-s-1_61.lib' 文件,现在一切正常。

我发现了mt-gd 和 mt-s library 之间的区别

于 2017-01-15T04:45:43.750 回答