2010-06-11 15 views
5

He intentado utilizar la biblioteca Boost pero falló, ver mi código:¿Cómo puedo usar la biblioteca Boost :: regex.hpp en C++?

#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); 
} 

Cuando intenté compilar consigo esos mensajes:

/usr/include/impulso/expresiones regulares/v4 /regex_match.hpp:50: referencia indefinida a `boost :: :: re_detail perl_matcher < __gnu_cxx :: __ normal_iterator, std :: asignador>>, std :: asignador, std :: asignador>>>>, boost :: regex_traits>

:: match()'

/usr/include/boost/regex/v4/basic_regex.hpp:425: referencia indefinida a `boost :: basic_regex>

:: do_assign (const char *, const char *, unsigned int)'

/usr/include/boost/regex/v4/perl_matcher.hpp:366: referencia indefinida a `impulsar :: :: re_detail perl_matcher < __gnu_cxx :: __ normal_iterator, std :: asignador>>, std :: asignador, std :: asignador>>>>, impulso :: regex_traits>

:: construct_init (boost :: basic_regex>> const &, impulso :: :: _ regex_constants match_flags)'

etc ...

Respuesta

4

Esos son errores de enlazador. La biblioteca de regex de Boost no es una biblioteca de solo encabezado como shared_ptr (por ejemplo); es necesario que establezca un vínculo con .a o .lib o con la biblioteca binaria que sea.

10

Es necesario que establezca un enlace a libboost_regex. Agregue -lboost_regex al interruptor del compilador si está utilizando gcc.

1

Debes crear un enlace contra boost_regex.

Cuestiones relacionadas