0

I am compiling an opensource project to run on my machine which is this project. It requires boost library so I installed the Boost_1_55 library on my ubuntu machine but the compiling process was not successfully finished by printing out some error messages as follows.

libtool: link: g++ -g -O3 -Wall -DKENLM_MAX_ORDER=6 -W -Wall -Wno-sign-compare -I./.. -pthread -I/usr/include -g -O2 -o .libs/query query_main.o  ./.libs/libklm.so ../util/.libs/libklm_util.so -lz -L/usr/lib/x86_64-linux-gnu -lboost_program_options -lboost_thread -lboost_system -lpthread -lrt -pthread
../util/.libs/libklm_util.so: undefined reference to `boost::thread::join()'
../util/.libs/libklm_util.so: undefined reference to `boost::thread::~thread()'
./.libs/libklm.so: undefined reference to `boost::thread::start_thread()'
collect2: ld returned 1 exit status

This answer seems the solution for my problem but the result of ls -al /usr/local/lib | grep thread showed me like below.

libboost_thread.a
libboost_thread.so -> libboost_thread.so.1.55.0
libboost_thread.so.1.49.0
libboost_thread.so.1.55.0

I don't know what else to check more. Thank you in advance for your help.

Community
  • 1
  • 1
  • These functions are all inline and defined in boost headers. You seem to have several versions of boost libraries on your system. Do you also have header versions corresponding to these libraries? – n. m. could be an AI Jul 12 '16 at 06:00
  • @n.m. Can you tell me how to check whether I have the proper header versions corresponding to the library? Actually, I don't exactly understand your point. Should header version match the library? – Thomas Kwon Jul 12 '16 at 06:19
  • #include "boost/version.hpp" and print BOOST_VERSION. – n. m. could be an AI Jul 12 '16 at 08:29
  • @n.m. I found out that current version of boost is 1_49 instead of 1_55 so your assumption was right. Then, how do I change the header version from 1.44 to 1.55? – Thomas Kwon Jul 12 '16 at 09:58
  • I followed these instructions [link](http://stackoverflow.com/q/6639881/3003942) and I used "BOOST_LIB_VERSION" to print the header version. – Thomas Kwon Jul 12 '16 at 10:00
  • @n.m. headers for boost lib are included from /usr/local/include, but the problem is these files belong to 1.49 which is old version. Thus, I deleted it so, there is no errors anymore! Thank you for your help. I really appreciate your comments. – Thomas Kwon Jul 12 '16 at 11:00

2 Answers2

0

You can try to add /usr/local/lib to LD_LIBRARY_PATH like this

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
phyxnj
  • 647
  • 5
  • 11
  • Thank you for giving me an answer. Unfortunately, It didn't work.. `$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
    $ echo $LD_LIBRARY_PATH
    /usr/local/lib:`
    $make`
    but it emits the same error messages.
    – Thomas Kwon Jul 12 '16 at 05:35
0

You have the static Boost library object (libboost_thread.so) but do you have the Boost development files installed? Check to see if the /usr/include/boost/thread directory exists and has *.hpp files in it. If not you may need to install the libboost-thread-dev package for your distribution or download the header files directly from Boost.org.

Josh Benson
  • 236
  • 3
  • 12
  • Thanks, I think it is installed also since there are more than 50 files in the /usr/include/boost/thread directory. – Thomas Kwon Jul 12 '16 at 05:53