这不是我第一次遇到此错误,但是[先前的解决方案] [1]没有任何意义。
[100%]链接CXX可执行文件../bin/qttest / usr / bin / x86_64-linux-gnu-ld:CMakeFiles / qttest.dir / src / main.cpp.o: 未定义对符号'_ZN5boost6system15system_categoryEv'的引用 /usr/lib/x86_64-linux-gnu/libboost_system.so:添加符号时出错: 命令行collect2中缺少DSO:错误:ld返回1退出 状态
这是我的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})
任何线索将不胜感激。
更改cmakelist后出现另一个问题
*** 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 –
答案 0 :(得分:1)
您应该将Boost库传递给target_link_libraries
命令。对文件的最小更改如下:
target_link_libraries(qttest ${QT_LIBRARIES} ${LIBS})
但是,由于您将find_package
用于Boost,实际上并没有在任何地方使用LIBS
变量,因此您应该坚持这样:
find_package(Boost COMPONENTS system REQUIRED)
...
target_link_libraries(qttest ${QT_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES})
并完全删除LIBS
。