【问题标题】:Undefined symbol while using boost:regex_error in C++?在 C++ 中使用 boost:regex_error 时未定义符号?
【发布时间】:2012-08-16 10:14:08
【问题描述】:

我正在使用 boost 库进行正则表达式,我使用 boost::regex() 函数来编译正则表达式。我必须捕获此函数调用引发的异常。所以我在 catch() 中使用了boost:regex_error

但是使用这个函数会报如下错误:

undefined symbol: _ZTIN5boost11regex_errorE

出现上述错误的原因是什么?

【问题讨论】:

  • 您需要链接到 boost 正则表达式库(您必须先构建该库)。

标签: c++ boost


【解决方案1】:

您必须与boost_regex 链接。在 GCC 上,将 -lboost_regex 添加到链接器调用中。其他编译器将具有等效选项。

【讨论】:

    【解决方案2】:
    $ c++filt _ZTIN5boost11regex_errorE
    typeinfo for boost::regex_error
    

    所以缺少类型信息。我认为您应该在启用 RTTI(运行时类型信息)的情况下编译您的项目。

    g++ undefined reference to typeinfo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-07
      • 2012-09-05
      • 1970-01-01
      • 2021-11-17
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多