|
Boost Users : |
Subject: [Boost-users] regex linker issue/
From: John Hendrix (jhendrix58_at_[hidden])
Date: 2011-01-06 12:25:48
Hi all,
I just downloaded boost and I am attempting to create a trivial program.
This my first attempt to develop boost on Fedora. Here is what I did:
1) downloaded boost_1_45_0
2) ./bootstrap.sh
3) ./bjam toolset=gcc variant=debug link=static --address-model=64
--with-regex
All of these step ran uneventfully
I then created a "hello world" regex program:
// regex-test.cpp
#include <string>
#include <iostream>
#include <boost/regex.hpp>
int main( int argc, char * argv[] )
{
// boost::regex pattern
("b.lug",boost::regex_constants::icase|boost::regex_constants::perl);
std::string stringa ("Searching for bolug");
std::string replace ("BgLug");
std::string newString;
// newString = boost::regex_replace (stringa, pattern, replace);
printf("The new string is: |%s|\n",newString.c_str());
return 0;
}
To compile and link:
g++ -o regex-test -I../../boost/boost_1_45_0/
-L../../boost/boost_1_45_0/stage/lib/ -lboost_regex regex-test.cpp
If all of the boost::whatever code is commented-out then it compiles and
links fine.
[root_at_fc5-virt64 upstream]# g++ -o regex-test -I../../boost/boost_1_45_0/
-L../../boost/boost_1_45_0/stage/lib/ -lboost_regex regex-test.cpp
[root_at_fc5-virt64 upstream]# ./regex-test
The new string is: ||
[root_at_fc5-virt64 upstream]#
However, if I, say, uncomment-out the first line of code I get:
[root_at_fc5-virt64 upstream]# g++ -o regex-test -I../../boost/boost_1_45_0/
-L../../boost/boost_1_45_0/stage/lib/ -lboost_regex regex-test.cpp
/tmp/ccDG8tmV.o: In function `boost::basic_regex<char,
boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char
const*, char const*, unsigned int)':
regex-test.cpp:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char,
boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char
const*, char const*, unsigned int)]+0x27): undefined reference to
`boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*,
unsigned int)'
collect2: ld returned 1 exit status
[root_at_fc5-virt64 upstream]#
Does anyone have any suggestions?
johnh
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net