English 中文(简体)
• 我如何利用C++的Boost:regex.hpp图书馆?
原标题:How can I use Boost::regex.hpp library in C++?

我试图使用Boost图书馆,但我没有看到我的代码:

#include "listy.h"
#include <boost/regex.hpp>
using namespace boost;

ListyCheck::ListyCheck() {

}

ListyCheck::~ListyCheck() {

}

bool ListyCheck::isValidItem(std::string &__item) {
    regex e("(\d{4}[- ]){3}\d{4}");

    return regex_match(__item, e);
}

当我试图将其汇编成册时,我收到以下信息:

/usr/include/boost/regex/v4/regex_match.hpp:50: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator > >, std::allocator, std::allocator > > > >, boost::regex_traits >

• 事项

/usr/include/boost/regex/v4/basic_regex.hpp:425: undefined reference to `boost::basic_regex >

•do_assign(char const*,char const*, unsign int)

/usr/include/boost/regex/v4/perl_matcher.hpp:366: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator > >, std::allocator, std::allocator > > > >, boost::regex_traits >

::construct_init(boost::basic_regex > > const&, boost::regex_constants::_match_flags)

......

最佳回答

这些是连接错误。 Boost regex图书馆不是像共享图书馆(例如)这样的头顶图书馆,你需要与图书馆或图书馆或任何双向图书馆连接。

问题回答

您需要与<代码>libboost_regex链接。 添加“密码>-lboost_regex,如果您重新使用gcc的话,则添加到汇编者开关上。

你们必须联系起来,反对提升。

也有类似的问题。

解决办法是把指挥目标链接图书馆连接起来:

target_link_libraries(boostGraph Boost::regex Boost::date_time Boost::system Boost::filesystem Boost::thread Boost::graph Boost::program_options)

这里提供的Syntax-lboost_regex没有工作(至少没有刀切)

根本问题可能是不同版本的图书馆,造成这一问题,即使汇编者和链接者确实找到了校准。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签