创建链接opencv的共享库时出现问题

时间:2019-03-12 09:41:02

标签: cmake

我创建了一个链接opencv的共享库并安装了共享库。

但是在我安装之后,使用opencv的程序一旦运行良好就会崩溃,并且错误如下:

/usr/bin/ld: can't find -lopencv_cvv

如果我在共享库中不使用opencv,则程序运行良好。

共享库的CMakelist.txt的核心如下:

  set(DEPENDENCIES realsense2 )
  add_library(TdLib SHARED
         threadSafeStructure/threadSafeStructure.cpp
         threadSafeStructure/threadSafeStructure.h
         realsense/realsense.cpp
         realsense/realsense.h
         )

 # OpenCV 
 find_package(OpenCV REQUIRED) 
 include_directories(${OPENCV_INCLUDE_DIRS})
 link_directories(${OpenCV_LIBRARY_DIRS})
 #PCL 
 find_package(PCL 1.8 REQUIRED) 
 include_directories(${PCL_INCLUDE_DIRS})
 link_directories(${PCL_LIBRARY_DIRS})

 set_target_properties(TdLib PROPERTIES
         PUBLIC_HEADER
         "realsense/realsense.h;threadSafeStructure/threadSafeStructure.h")
 target_link_libraries(TdLib
                     ${DEPENDENCIES}
                    ${OpenCV_LIBRARIES}
                     ${PCL_LIBRARIES})
 install(TARGETS TdLib
         # IMPORTANT: Add the foo library to the "export-set"
         EXPORT ${PROJECT_NAME}Targets
         RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
         LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
        PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/TdLibrary"
        COMPONENT dev)

您可以找到图书馆项目here

0 个答案:

没有答案