0

So I installed boost library as follows

cd /usr/local/
sudo tar --bzip2 -xf ~/Downloads/boost_1_52_0.tar.bz2
sudo ./bootsrap.sh
sudo ./b2 install

Now, I want to compile a code that uses boost library, and the makefile has these two lines to idenity the location of boost: (INC=.. and BOOSTLIB=..)

OBJS = utility.o PtDebug.o
CC = g++
INC = /usr/local/boost_1_52_0/
BOOSTLIB = /usr/local/include/boost/
CFLAGS = -Werror -g


all: my_program

and an example line of linking to boos in the makefile is

$(CC) $(FLAGS) $(OBJS)  ipMT.o -o ipmt -L$(BOOSTLIB) -lboost_date_time -lboost_thread

But when I try to make, it fails with this error:

g++  -Werror -g utility.o PtDebug.o  ratioWeightedCombIP.o -o rwcip -L/usr/local/include/boost/ -lboost_date_time -lboost_thread
/usr/bin/ld: utility.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
//usr/local/lib/libboost_system.so.1.57.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [misp] Error 1
2
  • 3
    you need to link boost_system Commented Jan 11, 2015 at 21:36
  • @Bot No, it certainly should not be migrated to Super User. This type of question is a totally valid for SO. Commented Jan 11, 2015 at 21:38

1 Answer 1

3

You are almost there. Add

-lboost_system

to your link line to yield (now with indentation)

$(CC) $(FLAGS) $(OBJS)  ipMT.o -o ipmt \
  -L$(BOOSTLIB) -lboost_date_time -lboost_thread -lboost_system

The error message gave you a hint: No symbol '_ZN5boost6system15system_categoryEv' which indicates that

  1. the symbol came from the Boost System namespace, hence suggesting that you need to link this, and
  2. offering a hint via a tool like c++filt

If you have c++filt you can see the mangled identifier expanded:

edd@max:~$ c++filt _ZN5boost6system15system_categoryEv
boost::system::system_category()
edd@max:~$ 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.