0

I'm trying to link my project against boost and another library that uses boost but haven't had success after hours spent tweaking my Makefile.

Myproject and dep1.a need boost to compile but I can't get to link with them.

The error I get is:

Parser.o): In function `boost::re_detail_107200::perl_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> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>)':

/deps/boost_1_72_0/boost/regex/v4/perl_matcher.hpp:391: undefined reference to `boost::re_detail_107200::perl_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)'

I need libboost_regex, libboost_system, and libboost_date_time.

Here is the Makefile code:

CC := g++

BASE_DIR := ../../../code/MyProject/

CC_FLAGS := -g -std=c++0x -I$(BASE_DIR)../dep1/include -I$(BASE_DIR)include
LD_FLAGS := -lrt -lpthread -L../../../../../deps/boost_1_72_0/stage/libboost_regex.a -L../../../../../deps/boost_1_72_0/stage/libboost_system.a -L../../../../../deps/boost_1_72_0/stage/libboost_date_time.a

CPP_FILES := $(wildcard $(BASE_DIR)src/*.cpp)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))

STATIC_DEP := ../dep1/lib/dep1.a


bin/MyProject: $(OBJ_FILES) $(STATIC_DEP)
    @mkdir -p $(@D)
    $(CC) -o $@ $^ $(STATIC_DEP) $(LD_FLAGS)

obj/%.o: $(BASE_DIR)src/%.cpp
    @mkdir -p $(@D)
    $(CC) $(CC_FLAGS) -c -o $@ $^

../dep1/lib/dep1.a:
    $(MAKE) -C ../dep1
clean:
    rm -rf ./obj
    rm -rf ./bin
'''
rturrado
  • 7,699
  • 6
  • 42
  • 62

0 Answers0