Problems using Boost, Pls Advise

S

sbobrows

{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}

Hi,

I'm a C++ newbie trying to use the Boost regex libraries. Here's my
situation.

My system is Red Hat Linux 9, using the Borland C++BuilderX Personal IDE
(which uses the g++ compiler).

I downloaded and installed Boost from boost.org using the command:

bjam -sTOOLS=gcc install

The install seemed to complete fine, with 2900+ targets updated.

The libraries install in /usr/local/include/boost-1_31/boost.

I created the following link:

ln -s /usr/local/include/boost-1_31/boost /usr/include/boost

I then use C++BuilderX to try and compile one of the example programs
for the regex libaries that I found in the documentation. The source
code is:

///////////////////////

#include <list>
#include <boost/regex.hpp>


unsigned tokenise(std::list<std::string>& l, std::string& s)
{
return boost::regex_split(std::back_inserter(l), s);
}

#include <iostream>
using namespace std;


#if defined(BOOST_MSVC) || (defined(__BORLANDC__) && (__BORLANDC__ ==
0x550))
//
// problem with std::getline under MSVC6sp3
istream& getline(istream& is, std::string& s)
{
s.erase();
char c = is.get();
while(c != '\n')
{
s.append(1, c);
c = is.get();
}
return is;
}
#endif


int main(int argc)
{
string s;
list<string> l;
do{
if(argc == 1)
{
cout << "Enter text to split (or \"quit\" to exit): ";
getline(cin, s);
if(s == "quit") break;
}
else
s = "This is a string of tokens";
unsigned result = tokenise(l, s);
cout << result << " tokens found" << endl;
cout << "The remaining text is: \"" << s << "\"" << endl;
while(l.size())
{
s = *(l.begin());
l.pop_front();
cout << s << endl;
}
}while(argc == 1);
return 0;
}


///////////////////////



The compiler returns the following errors:

///////////////////////

g++ -c -o /home/sbobrows/cbproject/pmetest/linux/Debug_Build/splittest.o
-g2 -O0 -MD -I/usr/include -I/usr/include/g++-3 splittest.cpp
g++ -o /home/sbobrows/cbproject/pmetest/linux/Debug_Build/pmetest
linux/Debug_Build/splittest.o
linux/Debug_Build/splittest.o(.text+0x2c9): In function `__tcf_0':
"stl_vector.h": /usr/include/c++/3.2.2/bits/stl_vector.h undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::~reg_expression [in-charge]()' at line 998
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail22get_default_expressionIcEERKNS_14reg_expressionIT_NS_12regex_traitsIS3_EESaIS
3_EEES3_+0x39):
In function `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> > const&
boost::re_detail::get_default_expression<char>(char)':
"perl_matcher_common.hpp":
/usr/include/boost/regex/v4/perl_matcher_common.hpp undefined reference
to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::reg_expression[in-charge](char const*, unsigned,
std::allocator<char> const&)' at line 734
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost11regex_splitISt20back_insert_iteratorISt4listISsSaISsEEEcSt11char_traitsIcESaIcENS_12reg
ex_traitsIcEES8_EEjT_RSbIT0_T1_T2_ERKNS_14reg_expressionISC_T3_T4_EENS_15regex_constants12_match_flagsEj+0x12e):
In function `unsigned
boost::regex_split<std::back_insert_iterator<std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
(std::back_insert_iterator<std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&,
boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> > const&, boost::regex_constants::_match_flags,
unsigned)':
"perl_matcher_non_recursive.hpp":
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::mark_count() const' at line 1059
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_
12regex_traitsIcEESaIcEEC1ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_14reg_expressionIcSB_SC_EENS_15regex_constants12_match_flagsE+0x78):
In function
`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
boost::regex_traits<char> said:
::perl_matcher[in-charge](__gnu_cxx::__normal_iterator<char const*,
, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
boost::match_results<__gnu_cxx::__normal_iterator<char const*,
, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > > >&, boost::reg_expression<char,
boost::regex_traits<char>, std::allocator<char> > const&,
boost::regex_constants::_match_flags)':
"perl_matcher_non_recursive.hpp":
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::get_traits() const' at line 869
':
"basic_string.tcc": /usr/include/c++/3.2.2/bits/basic_string.tcc
undefined reference to `boost::reg_expression<char,
boost::regex_traits<char>, std::allocator<char> >::empty() const' at
line 146
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_
12regex_traitsIcEESaIcEE24estimate_max_state_countEPSt26random_access_iterator_tag+0x30):
In function
`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
boost::regex_traits<char> said:
::estimate_max_state_count(std::random_access_iterator_tag*)':
"regex_grep.hpp": /usr/include/boost/regex/v4/regex_grep.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::size() const' at line 46
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_
12regex_traitsIcEESaIcEE8find_impEv+0xc0):
In function
`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >, boost::regex_traits<char>,
std::allocator<char> >::find_imp()':
"regex_grep.hpp": /usr/include/boost/regex/v4/regex_grep.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::mark_count() const' at line 49
Build cancelled due to errors
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_
12regex_traitsIcEESaIcEE8find_impEv+0x202):
In function
`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >, boost::regex_traits<char>,
std::allocator<char> >::find_imp()':
"perl_matcher_non_recursive.hpp":
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::mark_count() const' at line 767
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_
12regex_traitsIcEESaIcEE8find_impEv+0x290):
In function `__static_initialization_and_destruction_0':
"perl_matcher_non_recursive.hpp":
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::mark_count() const' at line 1254
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_
12regex_traitsIcEESaIcEE8find_impEv+0x2d7):
In function
`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >, boost::regex_traits<char>,
std::allocator<char> >::find_imp()':
"perl_matcher_common.hpp":
/usr/include/boost/regex/v4/perl_matcher_common.hpp undefined reference
to `boost::re_detail::verify_options(unsigned,
boost::regex_constants::_match_flags)' at line 821
linux/Debug_Build/splittest.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEESaIcEE5firstERKNS_14reg_expressionIcS3_S4_EE+0x
d):
In function `boost::re_detail::access_t<char, boost::regex_traits<char>,
std::allocator<char> >::first(boost::reg_expression<char,
boost::regex_traits<char>, std::allocator<char> > const&)':
"regex_split.hpp": /usr/include/boost/regex/v4/regex_split.hpp undefined
reference to `boost::reg_expression<char, boost::regex_traits<char>,
std::allocator<char> >::first(boost::reg_expression<char,
boost::regex_traits<char>, std::allocator<char> > const&) at line 36


///////////////////////


After searching around extensively, I've not come up with any solution
to my problem. Can someone please point me in the right direction? It
seems like I'm just missing some configuration step along the way.

Thanks in advance, Steve!
 
J

Julie

sbobrows said:
{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}
[big snip]

You are aware that there is a Boost newsgroup, right?

news://news.gmane.org/gmane.comp.lib.boost.devel

Seems that this would be much more topical there than here.
 
S

Steve Bobrowski

No, I did not. Sorry, I'll repost this there.

Thanks for your direction!

Steve

Julie said:
sbobrows said:
{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}
[big snip]

You are aware that there is a Boost newsgroup, right?

news://news.gmane.org/gmane.comp.lib.boost.devel

Seems that this would be much more topical there than here.
 
J

Julie

sbobrows said:
{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}
[big snip]

You are aware that there is a Boost newsgroup, right?

news://news.gmane.org/gmane.comp.lib.boost.devel

Seems that this would be much more topical there than here.
 
L

llewelly

sbobrows said:
{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}

Hi,

I'm a C++ newbie trying to use the Boost regex libraries. Here's my
situation.

My system is Red Hat Linux 9, using the Borland C++BuilderX Personal IDE
(which uses the g++ compiler).

I downloaded and installed Boost from boost.org using the command:

bjam -sTOOLS=gcc install

The install seemed to complete fine, with 2900+ targets updated.

The libraries install in /usr/local/include/boost-1_31/boost.

I created the following link:

ln -s /usr/local/include/boost-1_31/boost /usr/include/boost

I then use C++BuilderX to try and compile one of the example programs
for the regex libaries that I found in the documentation. The source
code is:
{quoted code snipped by mod. -mod/fwg}
[snip]

I don't know how to answer this without making the answer g++
specific. So those of you without g++, please bear with me.

Most libraries consist of two parts: header files, and binary
libraries containing compiled code. On most unicies, any error
about 'undefined reference to ...' or 'undefined symbol ...'
means the compiled binary libs were not found, or are
inconsistent with the header files.

You need to tell your compiler how to link in the binary library
containing the compiled code for boost::regex.

This will be different for each implementation, but for GCC, you must
tell the compiler two things:

(0) The name of the binary library, using '-l<library name>',
(1) The location of the library, using
'-L<directory containing compiled library>'

So your link command line should look something like this:

g++ linux/Debug_Build/splittest.o -lboost_regex -L/usr/local/lib

Finally see the gcc documentation: http://xrl.us/bx2p .
 
R

Richard Herring

[QUOTE="Julie said:
{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}
[big snip]

You are aware that there is a Boost newsgroup, right?

news://news.gmane.org/gmane.comp.lib.boost.devel

Seems that this would be much more topical there than here.[/QUOTE]

If it's server-specific, is it really a "newsgroup"?
 
J

Julie

Richard said:
[QUOTE="Julie said:
{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}
[big snip]

You are aware that there is a Boost newsgroup, right?

news://news.gmane.org/gmane.comp.lib.boost.devel

Seems that this would be much more topical there than here.

If it's server-specific, is it really a "newsgroup"?[/QUOTE]

Feel free to call it what you wish. I was merely pointing out that there is a
publicly available forum for the discussion of topic-specific items -- I prefer
to call that a newsgroup.
 
R

Richard Herring

[QUOTE="Julie said:
Julie <[email protected]> said:
sbobrows wrote:

{Whilst I think much of this is OT for this newsgroup, I think the issue
of understanding diagnostics just about gets under the door. -mod}
[big snip]

You are aware that there is a Boost newsgroup, right?

news://news.gmane.org/gmane.comp.lib.boost.devel

Seems that this would be much more topical there than here.

If it's server-specific, is it really a "newsgroup"?

Feel free to call it what you wish. I was merely pointing out that there is a
publicly available forum for the discussion of topic-specific items -- I prefer
to call that a newsgroup.[/QUOTE]

For a suitable definition of "publicly", maybe. If I can't ask the
newsmaster to add it to my local server, then I can't access it.

Which is why, if it doesn't follow the flood-filling propagation through
multiple servers characteristic of normal newsgroups, I'd prefer to call
it something else. "BBS accessible via NNTP", perhaps?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top