ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

linking boost components - catkin error

asked 2017-02-02 10:14:23 -0500

mr101470 gravatar image

updated 2017-12-06 16:28:49 -0500

M@t gravatar image

I followed most of the answers on how to link properly a library and still I cant compile my package with catkin_make, due to undefined reference to boost::log::v2s_mt_posix::trivial::logger::get()

Here is my the summary of my CMakeList.txt:

cmake_minimum_required(VERSION 2.8.3)
project(pleora_polarcam)

add_definitions(-std=c++11)

set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "-lboost_system") 
set(CMAKE_CXX_FLAGS "-lpthread")

find_package(catkin REQUIRED COMPONENTS
  roscpp
  cv_bridge
  image_transport
  dynamic_reconfigure
  driver_base
  camera_info_manager
)

find_package(OpenCV REQUIRED)
find_package(Boost 1.54 COMPONENTS log_setup log program_options thread REQUIRED)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES photonfocus_camera
  CATKIN_DEPENDS cv_bridge image_transport roscpp 
  DEPENDS system_lib
  DEPENDS Boost opencv 
)

include_directories(
  ${Boost_INCLUDE_DIR}
  ${catkin_INCLUDE_DIRS}
  ${EBUS_INCLUDE_DIRS}
  ${GNUTLS_INCLUDE_DIR}
)

add_executable(pix2image src/pix2image.cpp)

target_link_libraries(pix2image
  ${OpenCV_LIBRARIES}
  -lpthread
  ${Boost_LIBRARIES}
  ${catkin_LIBRARIES}
)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-02-02 15:42:46 -0500

mr101470 gravatar image

updated 2017-12-06 16:33:39 -0500

M@t gravatar image

The problem was solved by adding the following line in the beginning

add_definitions(-DBOOST_LOG_DYN_LINK=1)

and also changing ${Boost_INCLUDE_DIR} to ${Boost_INCLUDE_DIRS} (Note: "DIRS" not "DIR") as per the wiki page on CMakeLists.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-02 10:14:23 -0500

Seen: 2,529 times

Last updated: Dec 06 '17