【问题标题】:Boost regex linker error with cl 19使用 cl 19 提升正则表达式链接器错误
【发布时间】:2017-01-14 17:09:20
【问题描述】:

我使用 boost 1.61.0 和 cl 19 (visual studio 2015)。我使用命令行bootstrap.\b2从获取开始文档构建了boost库。这使得 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'

【问题讨论】:

    标签: c++ boost boost-regex cl


    【解决方案1】:

    我找到了解决办法。

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

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

    我在what's the difference between mt-gd and mt-s library找到了要点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 2011-07-29
      • 2017-01-26
      • 2011-06-26
      • 1970-01-01
      相关资源
      最近更新 更多