boost::regex - fail to compile a simple sample

Discussion in 'C++' started by FBergemann@web.de, Nov 3, 2006.

  1. Guest

    I use SunOS 5.8, gcc 3.3.2, boost 1.33.1.
    I have build the entire boost package and try to compile a simple
    example:

    #include <iostream>
    #include <string>
    #include <boost/regex.hpp> // Boost.Regex lib

    using namespace std;

    int main( ) {

    std::string s, sre;
    boost::regex re;

    while(true)
    {
    cout << "Expression: ";
    cin >> sre;
    if (sre == "quit")
    {
    break;
    }
    cout << "String: ";
    cin >> s;

    // Set up the regular expression for case-insensitivity
    re.assign(sre, boost::regex_constants::icase);
    if (boost::regex_match(s, re))
    {
    cout << re << " matches " << s << endl;
    }
    }
    }

    try to compile it this way [path for include files and static libs are
    ok]:

    > g++ -o test test.cc -I$ROOT/include/ -L$ROOT/lib -lboost_regex-gcc



    But i get:

    Undefined first referenced
    symbol in file
    boost::re_detail::c_traits_base::class_map /var/tmp//ccBM7Erf.o
    boost::re_detail::c_traits_base::lower_case_map
    /var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char>
    >::reg_expression[not-in-charge](std::allocator<char> const&)/var/tmp//ccBM7Erf.o

    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::size() const/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::empty() const/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::~reg_expression
    [not-in-charge]()/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::first(boost::reg_expression<char,
    boost::regex_traits<char>, std::allocator<char> >
    const&)/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::mark_count() const/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::can_start(char, unsigned char const*, unsigned
    char, boost::re_detail::_narrow_type const&)/var/tmp//ccBM7Erf.o
    boost::c_regex_traits<char>::transform_primary(std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >&,
    std::basic_string<char, std::char_traits<char>, std::allocator<char> >
    const&)/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::set_expression(char const*, char const*,
    unsigned)/var/tmp//ccBM7Erf.o
    boost::re_detail::raise_regex_exception(std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >
    const&)/var/tmp//ccBM7Erf.o
    boost::c_regex_traits<char>::transform(std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >&,
    std::basic_string<char, std::char_traits<char>, std::allocator<char> >
    const&)/var/tmp//ccBM7Erf.o
    boost::re_detail::c_traits_base::error_string(unsigned)/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::get_traits() const/var/tmp//ccBM7Erf.o
    boost::reg_expression<char, boost::regex_traits<char>,
    std::allocator<char> >::str() const/var/tmp//ccBM7Erf.o
    ld: fatal: Symbol referencing errors. No output written to test
    collect2: ld returned 1 exit status


    Can anybody help me?
    I already looked around the web, but didn't find a clue.

    Regards!

    Frank
     
    , Nov 3, 2006
    #1
    1. Advertising

  2. mlimber Guest

    wrote:
    > I use SunOS 5.8, gcc 3.3.2, boost 1.33.1.
    > I have build the entire boost package and try to compile a simple
    > example:
    >
    > #include <iostream>
    > #include <string>
    > #include <boost/regex.hpp> // Boost.Regex lib
    >
    > using namespace std;
    >
    > int main( ) {
    >
    > std::string s, sre;
    > boost::regex re;
    >
    > while(true)
    > {
    > cout << "Expression: ";
    > cin >> sre;
    > if (sre == "quit")
    > {
    > break;
    > }
    > cout << "String: ";
    > cin >> s;
    >
    > // Set up the regular expression for case-insensitivity
    > re.assign(sre, boost::regex_constants::icase);
    > if (boost::regex_match(s, re))
    > {
    > cout << re << " matches " << s << endl;
    > }
    > }
    > }
    >
    > try to compile it this way [path for include files and static libs are
    > ok]:
    >
    > > g++ -o test test.cc -I$ROOT/include/ -L$ROOT/lib -lboost_regex-gcc

    >
    >
    > But i get:
    >
    > Undefined first referenced
    > symbol in file
    > boost::re_detail::c_traits_base::class_map /var/tmp//ccBM7Erf.o
    > boost::re_detail::c_traits_base::lower_case_map
    > /var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char>
    > >::reg_expression[not-in-charge](std::allocator<char> const&)/var/tmp//ccBM7Erf.o

    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::size() const/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::empty() const/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::~reg_expression
    > [not-in-charge]()/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::first(boost::reg_expression<char,
    > boost::regex_traits<char>, std::allocator<char> >
    > const&)/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::mark_count() const/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::can_start(char, unsigned char const*, unsigned
    > char, boost::re_detail::_narrow_type const&)/var/tmp//ccBM7Erf.o
    > boost::c_regex_traits<char>::transform_primary(std::basic_string<char,
    > std::char_traits<char>, std::allocator<char> >&,
    > std::basic_string<char, std::char_traits<char>, std::allocator<char> >
    > const&)/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::set_expression(char const*, char const*,
    > unsigned)/var/tmp//ccBM7Erf.o
    > boost::re_detail::raise_regex_exception(std::basic_string<char,
    > std::char_traits<char>, std::allocator<char> >
    > const&)/var/tmp//ccBM7Erf.o
    > boost::c_regex_traits<char>::transform(std::basic_string<char,
    > std::char_traits<char>, std::allocator<char> >&,
    > std::basic_string<char, std::char_traits<char>, std::allocator<char> >
    > const&)/var/tmp//ccBM7Erf.o
    > boost::re_detail::c_traits_base::error_string(unsigned)/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::get_traits() const/var/tmp//ccBM7Erf.o
    > boost::reg_expression<char, boost::regex_traits<char>,
    > std::allocator<char> >::str() const/var/tmp//ccBM7Erf.o
    > ld: fatal: Symbol referencing errors. No output written to test
    > collect2: ld returned 1 exit status
    >
    >
    > Can anybody help me?
    > I already looked around the web, but didn't find a clue.
    >
    > Regards!
    >
    > Frank


    While you could certainly ask about how to use Boost.Regex here
    (because it is part of TR1), linker problems like this are really more
    of platform issue and should be addressed either on the Boost user list
    (http://boost.org/more/mailing_lists.htm#users) or on a group dedicated
    to your platform.

    Cheers! --M
     
    mlimber, Nov 3, 2006
    #2
    1. Advertising

  3. Guest

    "mlimber дµÀ£º
    "
    my question is :


    ompiling...
    Cpp1.cpp
    warning: STLPort debug versions are built with /D_STLP_DEBUG=1
    c:\c++\boost_1_33_1\boost\config\auto_link.hpp(211) : fatal error
    C1189: #error : "Build options aren't compatible with pre-built
    libraries"
    Error executing cl.exe.

    Cpp1.exe - 1 error(s), 1 warning(s)

    help me!
     
    , Dec 6, 2006
    #3
  4. Guest

    I'AM chinese .so i speak chinese.
    please use chinese-english translate software.
    if you don't understand what i said.I so sorry.
    Ðֵܣ¬ÄãµÄ´úÂëÎÒÔÚWINDOW
    ƽ̨ÉÏÃæÊÇ¿ÉÒÔ±àÒëͨ¹ýµÄ¡£

    ¶ÔÁËÒªÏëʹÓÃREGEX£¬ÄãµÄ»úÆ÷Àï±ØÐëÓÐ
    mine is
    libboost_regex-vc6-sgd-1_33_1.lib
    yours is
    libboost_regex-sunpro-sgd-1_33_1.lib


    ÎҵľÍÊÇÒòΪûÓÐÕâ¸ö¡£ËùÒÔ±àÒë²»¹ýÈ¥

    your code could compile in windows in vc6
    look up your lib,and find the "libboost_regex-vc6-sgd-1_33_1.lib"
    if not exists,you could compile the file
    "libboost_regex-vc6-sgd-1_33_1.lib"


    boost\libs\regex\build\
    then nmake(in windows is like this,but in sun ,I don't know) the
    sunpro.mak

    in default ,the libboost_regex-sunpro-sgd-1_33_1.lib isn't compiled
     
    , Dec 6, 2006
    #4
  5. Guest

    I'am so sorry!!


    > mine is
    > libboost_regex-vc6-sgd-1_33_1.lib
    > yours is
    > libboost_regex-sunpro-sgd-1_33_1.lib
    >
     
    , Dec 6, 2006
    #5
  6. Guest

    I'am so sorry!!


    > mine is
    > libboost_regex-vc6-sgd-1_33_1.lib
    > yours is
    > libboost_regex-sunpro-sgd-1_33_1.lib
    >
     
    , Dec 6, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Latter
    Replies:
    2
    Views:
    2,927
    Julie
    May 17, 2004
  2. Wenjie

    if (f() != FAIL) or if (FAIL != f())?

    Wenjie, Jul 28, 2003, in forum: C Programming
    Replies:
    3
    Views:
    478
    E. Robert Tisdale
    Jul 31, 2003
  3. Barry
    Replies:
    1
    Views:
    482
    Eric Niebler
    Jul 11, 2007
  4. Zorg
    Replies:
    0
    Views:
    435
  5. Zorg
    Replies:
    0
    Views:
    536
Loading...

Share This Page