【发布时间】:2010-03-16 22:31:58
【问题描述】:
我是 boost 新手,我想尝试一些实际的 .dll 部署场景,所以我使用以下命令编译/安装库:
.\bjam install --layout=system variant=debug runtime-link=shared link=shared
--with-date_time --with-thread --with-regex --with-filesystem
--includedir=<my include directory> --libdir=<my bin directory> > installlog.txt
这似乎可行,但我的简单程序(直接取自“入门”页面)失败了:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
// Place your functions after this line
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;
}
}
这会失败并出现以下链接器错误:
fatal error LNK1104: cannot open file 'libboost_regex-vc80-mt-1_42.lib'
我确定 .lib 和 .dll 都在该目录中,并命名了我希望它们的名称(即:boost_regex.lib 等,所有未版本化,正如 --layout=system 所说) .那么它为什么要寻找它的版本化类型呢?以及如何让它查找库的未版本化类型?
我已经尝试过使用更多“正常”选项,如下所示:
.\bjam stage --build-type=complete --with-date_time --with-thread --with-filesystem --with-regex > mybuildlog.txt
而且效果很好。我确保我的编译器看到了“stage\lib”目录,它编译并运行良好,除了让环境查看正确的 lib 目录之外,什么都没有。但是当我把那些“测试”目录拿走,并想使用其他的(未版本化的)时,它失败了。
我在 XP 上使用 VS2005。有什么想法吗?
【问题讨论】: