Results 1 to 10 of 10

Thread: Boost regex

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    43

    Boost regex

    Ok I'm using Bloodshed Dev-C++, but im also fine using vc++ 6.0. I downloaded the latest boost - boost_1_34_1.7z, and moved the boost folder into the include folder for devc++ and vc++, but when I try to compile something that uses boost regex I get too many errors. Someone help me?

    When I compile this example I got from somewhere I get this.

    Code:
    #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;
    
          try
          {
             // Set up the regular expression for case-insensitivity
             re.assign(sre, boost::regex_constants::icase);
          }
          catch (boost::regex_error& e)
          {
             cout << sre << " is not a valid regular expression: \""
                  << e.what() << "\"" << endl;
             continue;
          }
          if (boost::regex_match(s, re))
          {
             cout << re << " matches " << s << endl;
          }
       }
    return 0;
    }
    in vc++ I get 40 errors, so I'll just paste the first two:

    d:\program files\microsoft visual studio\vc98\include\utility(123) : warning C4786: 'std::_Tree<int,std:air<int const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::map<int,std::basic_string<char,std::char_traits<char
    >,std::allocator<char> >,std::less<int>,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Kfn,std::less<int>,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<c har> > > >::_Nil' : ide
    ntifier was truncated to '255' characters in the debug information
    d:\program files\microsoft visual studio\vc98\include\utility(123) : warning C4786: 'std::iterator<std::bidirectional_iterator_tag,std:air<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > const ,st
    d::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > >,int>' : identifier was truncated to '255' characters in the debug information
    d:\program files\microsoft visual studio\vc98\include\utility(123) : warning C4786: 'std::unary_function<std:air<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > const ,std::basic_string<unsigned s
    hort,std::char_traits<unsigned short>,std::allocator<unsigned short> > >,std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > >' : identifier was truncated to '255' characters in the debug information
    in devc++:

    40:2 D:\Program Files\Microsoft Visual Studio\MyProjects\Aah\Aahs.cpp [Warning] no newline at end of file
    [Linker error] undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
    [Linker error] undefined reference to `boost::re_detail:erl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match()'
    [Linker error] undefined reference to `boost::re_detail:erl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
    40:2 D:\Program Files\Microsoft Visual Studio\MyProjects\Aah\Aahs.cpp ld returned 1 exit status

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Boost regex

    The first 3 are compiler warnings. If you want to turn warnings off (some people are against it.. I personally love a "clean looking build".
    Code:
    // #pragma warning(disable:<number here>)
    #pragma warning(disable:4786)
    Don't use DevCPP.. its more useless than my mother trying to use a computer.

    As for the boost errors.. are you sure everything is in the right place? I know it can be a little hard at first.. but you need to make sure everything is where it should be (try copying it around to multiple areas.. ones bound to be correct).

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    43

    Re: Boost regex

    Ok I think I built it from instructions on here: http://www.boost.org/libs/regex/doc/install.html#vc


    but obviously I missed something..

    I tried to compile that same example and still get the same warnings / errors!

    Not gonna post all the warnings, the only error is:

    LINK : fatal error LNK1104: cannot open file "libboost_regex-vc6-sgd-1_34_1.lib"
    Last edited by BigLipsLeroy; Dec 5th, 2007 at 04:19 AM.

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Boost regex

    You need to add the library directories and link against the proper libraries. Surely thats apart of the instructions?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    43

    Re: Boost regex

    I have done that.

  6. #6
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Boost regex

    You haven't. This is what the compiler does..

    1) Searches for files in the working directory (where your code is).
    2) Searches for files in the compilers include directories
    3) Searches for files in directories you specify in the compiler settings.

    Thats what that linker error is.. it CANNOT find that file. If it does in fact exist.. then you need to make sure you add the directory its in.. to your linker options.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    43

    Re: Boost regex

    I have boost extracted to D:\boost_1_34_1

    All the directories are set up properly in dev-cpp and vcpp.

  8. #8
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Boost regex

    Where is "libboost_regex-vc6-sgd-1_34_1.lib" located?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  9. #9

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    43

    Re: Boost regex

    It ISN'T located anywhere. I followed the instructions here:
    http://72.14.203.104/translate_c?hl=...ial%26hs%3D70I

    When I run nmake on vc6.mak it makes:

    D:\Boost\libs\regex\build\vc6\libboost_regex-vc6-sgd-1_34.lib

    NOT

    D:\Boost\libs\regex\build\vc6\libboost_regex-vc6-sgd-1_34_1.lib

  10. #10
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Boost regex

    Change the outputted filename in the .mak file then.. open it with notepad..

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width