首页 > 解决方案 > 将 libconfig++ 添加到 CMake

问题描述

我正在尝试添加libconfig++到我的 CMake 项目中,但它仍然抱怨

Libconfig library is config++
...
CMakeFiles/CustomCamReaderTask.dir/acA2440-20gc_ConfigUtility.cc.o: undefined reference to symbol '_ZN13ConfigSection3getERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERl'
.../lib/libconfig.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

这是我的CMakeLists.txt

find_package(PkgConfig)
pkg_check_modules(LIBCONFIG_PLUSPLUS libconfig++ REQUIRED)

add_executable(CustomCamReaderTask
    CustomCamReaderTask.cc
    acA2440-20gc_ConfigUtility.cc)

target_include_directories(CustomCamReaderTask
    PRIVATE ${CMAKE_SOURCE_DIR}/src/include/Pylon5
    /opt/pylon5/include)

message("Libconfig library is ${LIBCONFIG_PLUSPLUS_LIBRARIES}")

target_link_libraries(CustomCamReaderTask
    ${LIBCONFIG_PLUSPLUS_LIBRARIES}
    ${PYLON_LIBS}
    task
    imageUtility
    ${OPENCV_LIBRARIES})

link_directories(/opt/pylon5/lib64)
link_libraries(${LIBCONFIG_PLUSPLUS_LIBRARIES})

好像找到了config++,我链接了目录,链接了库,不知道还有什么问题..

标签: cmakelibconfig

解决方案


推荐阅读