致命错误 LNK1104:无法打开文件“libboost_regex-vc90-mt-gd-1_42.lib”
我正在尝试在我的程序中使用 boost 正则表达式 问题是我收到这个错误... 我所做的唯一安装步骤是添加:“C:\Program Files\boost\boost_1_42” 进入附加包含目录...
我正在使用 VS2008...
尝试实现这个:
#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace std;
int main( ) {
std::string s, sre;
boost::regex re;
boost::cmatch matches;
while(true)
{
cout << "Expression: ";
cin >> sre;
if (sre == "quit")
{
break;
}
cout << "String: ";
cin >> s;
try
{
// Assignment and construction initialize the FSM used
// for regexp parsing
re = sre;
}
catch (boost::regex_error& e)
{
cout << sre << " is not a valid regular expression: \""
<< e.what() << "\"" << endl;
continue;
}
// if (boost::regex_match(s.begin(), s.end(), re))
if (boost::regex_match(s.c_str(), matches, re))
{
// matches[0] contains the original string. matches[n]
// contains a sub_match object for each matching
// subexpression
for (int i = 1; i < matches.size(); i++)
{
// sub_match::first and sub_match::second are iterators that
// refer to the first and one past the last chars of the
// matching subexpression
string match(matches[i].first, matches[i].second);
cout << "\tmatches[" << i << "] = " << match << endl;
}
}
else
{
cout << "The regexp \"" << re << "\" does not match \"" << s << "\"" << endl;
}
}
}
似乎是什么问题?应该进行任何额外的设置吗?
i'm trying to use boost regex within my program
the problem is i get this error...
the only installation step i did was to add: "C:\Program Files\boost\boost_1_42"
into the Additional Include Directories...
i'm using VS2008...
trying to implement this:
#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace std;
int main( ) {
std::string s, sre;
boost::regex re;
boost::cmatch matches;
while(true)
{
cout << "Expression: ";
cin >> sre;
if (sre == "quit")
{
break;
}
cout << "String: ";
cin >> s;
try
{
// Assignment and construction initialize the FSM used
// for regexp parsing
re = sre;
}
catch (boost::regex_error& e)
{
cout << sre << " is not a valid regular expression: \""
<< e.what() << "\"" << endl;
continue;
}
// if (boost::regex_match(s.begin(), s.end(), re))
if (boost::regex_match(s.c_str(), matches, re))
{
// matches[0] contains the original string. matches[n]
// contains a sub_match object for each matching
// subexpression
for (int i = 1; i < matches.size(); i++)
{
// sub_match::first and sub_match::second are iterators that
// refer to the first and one past the last chars of the
// matching subexpression
string match(matches[i].first, matches[i].second);
cout << "\tmatches[" << i << "] = " << match << endl;
}
}
else
{
cout << "The regexp \"" << re << "\" does not match \"" << s << "\"" << endl;
}
}
}
what seems to be the problem ? any additional settings should be made ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
必须构建一些 Boost 库;这是其中之一。构建它们的方法如下:
创建一个名为
boost_build.bat
的新文件,并在里面放入:注释 9.0 指的是 VS 2008。(10.0 表示 2010 年,8.0 表示 2005 年,7.1 表示 2003 年,6.0 表示,嗯,6.0)。完成此操作后:
将
build_boost.bat
提取到转到:
\tools\jam
并运行
build_dist.bat
将< /code>
\tools\jam\stage\bin.ntx86\bjam.exe
复制到运行 < code>boost_build.bat
库位于\stage\lib
注意,这是我自己的方法。如果有人以更简单的方式附和,或者来自 Boost 的一些链接,我会喜欢;似乎很难从 Boost 找到正确的构建指令。
一旦构建完成,请确保让编译器知道库在 VC 目录(库路径)中的位置;添加“
\stage\lib
”。在
bjam
定义中,我有_SECURE_SCL=0
_HAS_ITERATOR_DEBUGGING=0
用于发布。这会禁用发布版本中的所有迭代器检查,以提高速度。Some Boost libraries have to be built; this is one of them. Here's how you can build them:
Make a new file called
boost_build.bat
, and inside put:Note 9.0 refers to VS 2008. (10.0 for 2010, 8.0 for 2005, 7.1 for 2003, 6.0 for, well, 6.0). Once you've done this:
Extract
build_boost.bat
to<boost_root>
Go to:
<boost_root>\tools\jam
And run
build_dist.bat
Copy
<boost_root>\tools\jam\stage\bin.ntx86\bjam.exe
to<boost_root>
Run
boost_build.bat
Libraries are located in
<boost_root>\stage\lib
Note, this is my own method. I would love if someone chimed in an easier way, or some link from Boost; it seems it's difficult to find proper build instructions from Boost.
Once it's built, make sure you let the compiler know where the libraries are in your VC Directories (the Library Paths); add "
<boost_root>\stage\lib
".In the
bjam
defines, I have_SECURE_SCL=0
_HAS_ITERATOR_DEBUGGING=0
for Release. This disables all iterator checking in Release builds, for a speed improvement.在 Windows 上,获取 boost 二进制库的最简单方法是运行来自 BoostPro Advisory 的安装程序。请务必选择您的 Visual Studio 版本,并在安装过程中选中正则表达式库复选框。
On Windows, the easiest way to get boost binary libraries is to run the installer from BoostPro consulting. Be sure to select your version of Visual Studio and check the box for the regex library during the install.
你安装了Boost的多线程调试版本吗?如果没有,请这样做。否则,请检查您的库路径(在项目首选项中),以便它包含错误消息中提到的文件的路径。
Have you installed the multithreading debug version of Boost? If not, please do so. Otherwise check your library path (in the project preferences) so that it includes the path to the file mentioned in the error message.
我不确定定义设置,但我能够通过运行
\bootstrap
批处理文件,然后编辑来使用 MSVC 9.0 进行构建。 \project-config.jam
文件如下。将行:更改为:,
然后运行
.\b2 install
并且 boost 标头和库已构建并安装到c:\boost
。I'm not sure about the define settings, but I was able to get boost to build with MSVC 9.0 by running the
<boostroot>\bootstrap
batch file, then editing<boostroot>\project-config.jam
file as follows. Change the line:to:
then running
.\b2 install
and the boost headers and libraries were built and installed toc:\boost
.