0
votes

this is not the first time I meet this error, but [previous solution][1] doesn't make sense.

[100%] Linking CXX executable ../bin/qttest /usr/bin/x86_64-linux-gnu-ld: CMakeFiles/qttest.dir/src/main.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

here is my cmakelists

cmake_minimum_required(VERSION 2.4.6)
set(OpenCV_DIR "/usr/local/opencv-2.4.9/share/OpenCV")
include_directories("/usr/local/opencv-2.4.9/include")
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
find_package(Qt4 COMPONENTS QtCore QtGui)
find_package(OpenCV 2.4.9 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
rosbuild_init()
rosbuild_genmsg()
find_package(Boost COMPONENTS system REQUIRED)
set(qt_srcs
    src/mainwindow.cpp
    src/listnerthr.cpp
    src/ros_thr.cpp
    src/CreatDataBuffer.cpp
    src/CreatBuffer.cpp
    src/pid_controller.cpp
    src/low_pass_filter.cpp

    src/plot_publisher.cpp)
set(qt_hdrs
    src/mainwindow.h
    src/listnerthr.h
    src/ros_thr.h
    src/CreatDataBuffer.h
    src/HelperFunctions.h
    src/CreatBuffer.h
    src/pid_controller.h
    src/low_pass_filter.h

    src/plot_publisher.h)
qt4_automoc(${qt_srcs})
QT4_WRAP_CPP(qt_moc_srcs ${qt_hdrs})
QT4_WRAP_UI(uis_h src/mainwindow.ui)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_executable(qttest src/main.cpp
    ${uis_h} ${qt_srcs} ${qt_moc_srcs})
target_link_libraries(qttest ${QT_LIBRARIES}${Boost_LIBARAIES }${OpenCV_LIBARAIES})

any clues would be appreciated.


I got another problem after changing the cmakelists

*** No rule to make target '/usr/lib/x86_64-linux-gnu/libboost_system.so/usr/lib/x86_64-linux-gnu/libboost_system.so', needed by '../bin/qttest'. Stop. CMakeFiles/Makefile2:425: recipe for target 'CMakeFiles/qttest.dir/all' failed –
1
You do not pass boost libraries to target_link_libraries - ixSci
What is ${Boost_LIBS }? And why you don't have a whitespace following this variable? Copy the line from my answer exactly. - ixSci
@ixSci,I am so sorry about this careless mistake. I already modified and checked the cmakelists that I am using. but that problem still exists. - TENG FEI HAN

1 Answers

1
votes

You should pass boost libraries to the target_link_libraries command. The smallest change to your file will be as follows:

target_link_libraries(qttest ${QT_LIBRARIES} ${LIBS})

But since you are using find_package for Boost and you do not actually use your LIBS variable anywhere, you should stick with something like this:

find_package(Boost COMPONENTS system REQUIRED)
...
target_link_libraries(qttest ${QT_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES})

And remove LIBS altogether.