0

I am trying to compile a library which has boost as a dependency. While compiling it with cmake I receive the following error:

../libdasp/libdasp.so: error: undefined reference to 'boost::system::system_category()' ../libdasp/libdasp.so: error: undefined reference to 'boost::system::generic_category()'

I have installed boost 1.62 manually using the instructions on this page on my ubuntu 12.04 machine. In order to avoid any path related inconsistency, I removed the default libboost-dev (1.48) using apt and installed the new boost to /usr.

I have looked for similar questions on stackoverflow, and they ask to add -lboost_system or something similar. But I cannot understand how can I force cmake to look for this specific library when rest of the files compiles successfully using the same library (indicating my boost installation is not flawed). The CMakeLists file giving the error is here

I executed the following command

locate boost_system

and the output is

/usr/lib/libboost_system.a

/usr/lib/libboost_system.so

/usr/lib/libboost_system.so.1.46.1

Any answers or pointers would be really helpful.

1 Answer 1

3

try:

set(BOOST_ROOT <where you built boost>)

find_package(Boost COMPONENTS program_options signals thread system)
find_package(Threads)

...

target_link_libraries(target ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(target PUBLIC SYSTEM ${Boost_INCLUDE_DIRS})

remove these:

boost_signals
boost_thread
boost_program_options
boost_system
pthread

documentation here: https://cmake.org/cmake/help/v3.0/module/FindBoost.html

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.