I'm new to the syntax of Makefiles and I'm not sure how can I properly link to boost library thread definitions.
In the .cpp file, I have this code:
boost::thread(&MessageBus::readBus, this, _bus).detach();
I have included following:
#include <boost/thread.hpp>
But while compiling I get the following error which seems to be because of linking issues:
../../../../bsl1/boost/boost/thread/detail/thread.hpp:255: undefined reference to `boost::thread::detach()'
Consolidator.o: In function `~thread_data':
../../../../bsl1/boost/boost/thread/detail/thread.hpp:93: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
../../../../bsl1/boost/boost/thread/detail/thread.hpp:93: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
Consolidator.o: In function `thread_data_base':
../../../../bsl1/boost/boost/thread/pthread/thread_data.hpp:144: undefined reference to `vtable for boost::detail::thread_data_base'
Consolidator.o: In function `thread_data':
../../../../external/bsl1/boost/boost/thread/detail/thread.hpp:111: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
Consolidator.o: In function `boost::thread::start_thread()':
../../../../bsl1/boost/boost/thread/detail/thread.hpp:180: undefined reference to `boost::thread::start_thread_noexcept()'
In Makefile, I have added boost lib in both CFLAGS and CXXFLAGS:
PROG = msgbusd
NO_STRIP = yes
.PATH: \
${.CURDIR}/server \
SRCS += \
main.cpp \
oc.cpp \
UdpReceiver.cpp \
${OTHER_SRCS} \
${LIB_PROTOS_SRCS} \
CXXFLAGS += \
-fpermissive \
-I${SRCTOP_EXTERNAL}/bsl1/boost
CFLAGS += \
-DBOOST_SYSTEM_NO_DEPRECATED \
-fno-inline \
-I${.CURDIR}/server \
-I${.CURDIR}/lib/h \
-I. \
-I${SRCTOP_EXTERNAL}/bsl1/boost
DPLIBS += \
${LIBXSLT} \
${LIBISC} \
${LIBBSDXML} \
${LIBXML2} \
${LIBEVENT} \
${LIBPTHREAD} \
${LIBZ}
.include <bsd.prog.mk>
I'm developing in FreeBSD 6 and has gcc 4.2.
What other changes I need to do in order to be able to compile it successfully?
Already went through this thread, and didn't find anything specific to Makefile and Makefile syntax to include boost libraries