Hi,

I'm just settign up boost on my desktop (ubuntu) after a reinstall and am having some problems. I set it up last w/e on my laptop (knoppix) and did exactly the same thing and it works fine. I'm sure its something increadably simple I'm missing. I'm following http://www.boost.org/doc/libs/1_53_0/more/getting_started/unix-variants.html

I'm testign the compiled libs using the test program.

#include <boost/regex.hpp>
#include <iostream>
#include <string>

int main()
{
    std::string line;
    boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );

    while (std::cin)
    {
        std::getline(std::cin, line);
        boost::smatch matches;
        if (boost::regex_match(line, matches, pat))
            std::cout << matches[2] << std::endl;
    }
}

Compilation works fine.

g++ -c -Wall -I/usr/local/include/boost/ t1.cpp -o t1.o

but linking fails

$ g++ -L/usr/local/lib -lboost_regex t1.o -o t2
t1.o: In function `bool boost::regex_match<__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> > > > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, bla bla bla bla

My path is correct

ls -l /usr/local/lib/libboost_regex.*
-rw-r--r-- 1 root root 2703774 2013-02-05 21:07 /usr/local/lib/libboost_regex.a
lrwxrwxrwx 1 root root      24 2013-02-05 21:03 /usr/local/lib/libboost_regex.so -> libboost_regex.so.1.53.0
-rwxr-xr-x 1 root root 1318409 2013-02-05 21:03 /usr/local/lib/libboost_regex.so.1.53.0

I've only got one version installed.

libs

$ locate boost|grep regex.so
/usr/local/lib/libboost_regex.so
/usr/local/lib/libboost_regex.so.1.53.0

headers

$ locate boost|grep regex*.hpp
/usr/local/include/boost/cregex.hpp
/usr/local/include/boost/regex.hpp
/usr/local/include/boost/algorithm/string_regex.hpp
/usr/local/include/boost/algorithm/string/regex.hpp
/usr/local/include/boost/algorithm/string/detail/finder_regex.hpp
/usr/local/include/boost/algorithm/string/detail/formatter_regex.hpp
/usr/local/include/boost/iostreams/filter/regex.hpp
/usr/local/include/boost/regex/v4/basic_regex.hpp
/usr/local/include/boost/regex/v4/cregex.hpp
/usr/local/include/boost/regex/v4/regex.hpp
/usr/local/include/boost/spirit/home/classic/utility/regex.hpp
/usr/local/include/boost/spirit/include/classic_regex.hpp
/usr/local/include/boost/tr1/regex.hpp
/usr/local/include/boost/xpressive/basic_regex.hpp

I've installed boost before and as I said, even as recently as last week, no bother.

I'm sure its something increadably simple I'm missing, but a pointer would be good.

Fails with my make file that works fin on my laptop too.

BOOSTINC=/usr/local/include/boost/
# include/boost/
BOOSTLIBS=/usr/local/lib/

CXX=g++
CFLAGS=-c -Wall -I$(BOOSTINC)
CXX_LDFLAGS=-L$(BOOSTLIBS)
#LIBRARIES=-lboost_thread
LIBRARIES=-lboost_regex

SOURCES=t1.cpp
OBJECTS=$(SOURCES:.cpp=.o)

EXECUTABLE=t2


CXX_COMPILE=$(CXX) $(CFLAGS)
CXX_LINK=$(CXX) $(CXX_LDFLAGS) $(LIBRARIES)

all: $(SOURCES) $(EXECUTABLE)


$(EXECUTABLE): $(OBJECTS)
    $(CXX_LINK) $(OBJECTS) -o $@



.cpp.o:
    $(CXX_COMPILE) $< -o $@


clean:
    rm -rf *o hello

Any help greatfully recived.

sorted. Command line arguments round the wrong way. I knew it was something stupid. Amzing hte diffrence a fresh head makes.

 g++ t1.o -o t2 -L/usr/local/lib -lboost_regex 

Question is though when did this not matter oon my laptop?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.