我是新手,并且认为我会尝试使用.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
Run Code Online (Sandbox Code Playgroud)
这似乎有效,但我的简单程序(从"入门"页面开始)失败了:
#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;
}
}
Run Code Online (Sandbox Code Playgroud)
这会因以下链接器错误而失败:
fatal error LNK1104: cannot open file 'libboost_regex-vc80-mt-1_42.lib'
Run Code Online (Sandbox Code Playgroud)
我确信.lib和.dll都在该目录中,并命名我希望它们如何(例如:boost_regex.lib等,所有未版本化,如--layout =系统所说).那么为什么要寻找它的版本化类型呢?我如何让它来寻找未版本化的库类型?
我已尝试使用更多"正常"选项,如下所示:
.\bjam stage --build-type=complete --with-date_time --with-thread --with-filesystem --with-regex > mybuildlog.txt
Run Code Online (Sandbox Code Playgroud)
这很好.我确保我的编译器看到了"stage\lib"目录,并且编译并运行正常,除了让环境查看正确的lib目录之外什么都没有.但是,当我把那些"测试"目录拿走,并想要使用其他这些(无版本)时,它就失败了.
我在XP下的VS2005.有任何想法吗?
快速回答,因为我无法在家中访问Visual C++.
我相信你正在与Visual C++编译器上Boost的"自动链接"发生冲突.
解决方案是禁用"自动链接"(请参阅您的文档:快速谷歌搜索显示宏"BOOST_ALL_NO_LIB"以禁用所有Boost库的自动链接),然后将您的项目明确链接到正确的库.
我会尽快更新这个答案.
| 归档时间: |
|
| 查看次数: |
1521 次 |
| 最近记录: |