致命错误 LNK1104:无法打开文件“libboost_regex-vc90-mt-gd-1_42.lib”

发布于 2024-08-21 07:29:51 字数 1792 浏览 6 评论 0原文

我正在尝试在我的程序中使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风吹雪碎 2024-08-28 07:29:51

必须构建一些 Boost 库;这是其中之一。构建它们的方法如下:

创建一个名为 boost_build.bat 的新文件,并在里面放入:

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

注释 9.0 指的是 VS 2008。(10.0 表示 2010 年,8.0 表示 2005 年,7.1 表示 2003 年,6.0 表示,嗯,6.0)。完成此操作后:

  1. build_boost.bat 提取到

  2. 转到:
    \tools\jam
    并运行 build_dist.bat

  3. \tools\jam\stage\bin.ntx86\bjam.exe 复制到 < /code>

  4. 运行 < code>boost_build.bat

  5. 库位于 \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:

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:

  1. Extract build_boost.bat to <boost_root>

  2. Go to:
    <boost_root>\tools\jam
    And run build_dist.bat

  3. Copy <boost_root>\tools\jam\stage\bin.ntx86\bjam.exe to <boost_root>

  4. Run boost_build.bat

  5. 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.

灵芸 2024-08-28 07:29:51

在 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.

余生一个溪 2024-08-28 07:29:51

你安装了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.

请持续率性 2024-08-28 07:29:51

我不确定定义设置,但我能够通过运行 \bootstrap 批处理文件,然后编辑 来使用 MSVC 9.0 进行构建。 \project-config.jam 文件如下。将行:更改

using mvsc

为:,

using msvc : 9.0 : cl.exe

然后运行 ​​.\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:

using mvsc

to:

using msvc : 9.0 : cl.exe

then running .\b2 install and the boost headers and libraries were built and installed to c:\boost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文