【问题标题】:How to use boost::wregex? [duplicate]如何使用 boost::wregex? [复制]
【发布时间】:2019-02-24 12:50:35
【问题描述】:

我使用 wregex 作为以下 C++ 代码。但它不起作用,你能帮帮我吗?欢迎任何建议。

#include <boost/regex.hpp>
namespace abc
{
    int ClassName::fun1()
    {
        wstring wp1 = _String2Wstring(p1); // This a function defined by myself.
        boost::wregex wreg(wp1,boost::regex::perl|boost::regbase::icase);
        ......
    }
}

我可以在centos 7中成功编译一个.so文件。但是当我启动我的应用程序时。我在网站http://demangler.com/的日志文件中收到以下消息

undefined symbol: boost::basic_regex<wchar_t, 
boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > 
>::do_assign(wchar_t const*, wchar_t const*, unsigned int)

如果删除以下代码,我可以启动我的应用程序。所以我认为错误来自这段代码。但我很困惑找不到答案。谢谢。

boost::wregex wreg(wp1,boost::regex::perl|boost::regbase::icase);

【问题讨论】:

标签: c++ regex boost


【解决方案1】:

我认为您并没有对链接器说要链接到 boost_regex。 如果您使用 GCC,请添加链接器标志 -lboost_regex。其他编译器需要类似的标志。

【讨论】:

  • 我使用 cmake 和 make 来编译我的项目。如何添加链接器标志?我试图通过谷歌找到答案,但失败了。
  • 看看这个页面:stackoverflow.com/a/6646518/855844
猜你喜欢
  • 2013-07-20
  • 2012-01-25
  • 1970-01-01
  • 1970-01-01
  • 2013-07-20
  • 2013-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多