致命错误LNK1104:无法打开文件'libboost_regex-vc90-mt-gd-1_42.lib' [英] fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_42.lib'
问题描述
我想在我的程序中使用boost regex
的问题是我得到这个错误...
唯一的安装步骤,我做的是添加: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>>斯雷
if(sre ==quit)
{
break;
}
cout<< String:;
cin>> s;
try
{
//分配和构造初始化FSM使用
//用于regexp解析
re = sre;
}
catch(boost :: regex_error& e)
{
cout< sre<< 不是有效的正则表达式:\
<< e.what()<<\< endl;
continue;
}
if(boost :: regex_match(s.begin(),s.end(),re))
if(boost :: regex_match(s.c_str matches,re))
{
// matches [0]包含原始字符串。匹配[n]
//每个匹配的
包含一个sub_match对象
for(int i = 1; i< matches.size(); i ++)
{
// sub_match :: first和sub_match :: second是迭代器,
//引用
的最后一个字符的前一个字符//匹配子表达式
字符串match(matches [i] .first,matches [i] .second);
cout<< \tmatches [<< i<< ] =<匹配<< endl;
}
}
else
{
cout< regexp \<< re<<\不匹配\<< s<<\< endl;
}
}
}
什么似乎是问题?
必须构建一些Boost库;这是其中之一。
创建一个名为 boost_build.bat
的新文件, p>
bjam toolset = msvc-9.0 variant = release threading = multi link = static define = _SECURE_SCL = 0 define = _HAS_ITERATOR_DEBUGGING = 0
bjam toolset = msvc-9.0 variant = debug threading = multi link = static
2010年为10.0,2005年为8.0,2003年为7.1,6.0,6.0,6.0)。完成此操作后:
-
提取
build_boost.bat
< boost_root>
-
前往:
boost_root> \tools\jam
并运行build_dist.bat
-
将
< boost_root> \tools\jam\stage\bin.ntx86\bjam.exe
复制到< ; boost_root>
-
运行
boost_build.bat
/ li>
-
图书馆位于
< boost_root> \stage\lib
注意,这是我自己的方法。我会爱如果有人用更简单的方式,或一些链接从Boost;它似乎很难找到正确的构建指令从Boost。
一旦它建立,确保你让编译器知道库在你的VC目录(库路径);添加< boost_root> \stage\lib
。
在 bjam
定义中,我有 _SECURE_SCL = 0
_HAS_ITERATOR_DEBUGGING = code>用于发布。这将禁用发布版本中的所有迭代器检查,以提高速度。
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 ?
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:
bjam toolset=msvc-9.0 variant=release threading=multi link=static define=_SECURE_SCL=0 define=_HAS_ITERATOR_DEBUGGING=0
bjam toolset=msvc-9.0 variant=debug threading=multi link=static
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 runbuild_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.
这篇关于致命错误LNK1104:无法打开文件'libboost_regex-vc90-mt-gd-1_42.lib'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!