ROS、opencv3 和 CMake - 无法删除库

ROS, opencv3 and CMake - unable to remove the library

工作环境:

出于某种未知原因,我决定安装 ros-indigo-opencv3 软件包,我几乎立刻就后悔了,因为我也有 [=] 附带的默认版本94=] 14.04 - OpenCV 2.4.8.

起初我注意到 QtCreator 在构建我的 CMake 项目时警告我 2.4.8 和 3.0.0 之间可能不兼容(你可以看到这个 [=92] 末尾的 CMakeLists.txt =]) 仅使用

find_package(OpenCV REQUIRED)

然后错误开始围绕 cv::stereoSGBM 模块缺少一些引用。命名空间或其他内容似乎有一些变化,我正在使用的库使用 OpenCV 的 2.x 分支(显然发现困难的方式:D)因此我告诉自己 - 我想我会删除上面提到的OpenCV 3.0.0 的 ROS 包并坚持使用 2.4.8.

卸载该软件包后,一切都崩溃了。即使在我项目的 CMakeLists.txt 中,我明确指出版本 2.4.8。待用

find_package(OpenCV 2.4.8 REQUIRED)

在使用 roslaunch 启动我的节点后立即死机并出现以下错误:

.../pmd_nano_node: error while loading shared libraries: libopencv_highgui.so.3.0: cannot open shared object file: No such file or directory

嗯...好吧...我检查了我的系统上是否遗留了一些东西(可能是坏包,无法安装并相应地正确安装?)。令我惊讶的是调用 locate 并用 grep

传递结果
user:~$ locate libopencv | grep 3.0

我得到了

/opt/ros/indigo/lib/libopencv_calib3d.so.3.0
/opt/ros/indigo/lib/libopencv_calib3d.so.3.0.0
/opt/ros/indigo/lib/libopencv_core.so.3.0
/opt/ros/indigo/lib/libopencv_core.so.3.0.0
...

(basically all opencv libs)

所以毕竟有些东西留在那里(我的意思是一切 :D)。然而想象一下当我 cd-ed 到 /opt/ros/indigo/lib/ 并且发现没有一个文件甚至与 OpenCV 远程相关时我的惊讶更不用说了OpenCV 3.0.0.

使用 pkg-config returns 我至少期望的是:

user:~$ pkg-config --cflags opencv
-I/usr/include/opencv
user:~$ pkg-config --libs opencv
/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so ...
-lopencv_calib3d ...

注意:我仍然不知道为什么 --cflags 从不显示 opencv2 包含文件夹(无法识别 opencv2 作为参数通过 pkg-config)

进一步的调查让我重新运行我的CMakeLists.txt我的项目与3.0.0版本作为要求,实际上CMake现在抱怨只有找到 2.4.8。尽管应用程序试图获取 3.0.0 版本的 OpenCV 共享库的原因还有待观察。

任何建议或以前遇到过此类问题的人?

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(pmd_nano)

SET(CMAKE_CXX_FLAGS "-std=c++0x -fpermissive -Wno-deprecated -Wno-sign-compare")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_CXX_LINK_FLAGS_DEBUG "-pg")

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  pcl_conversions
  pcl_msgs
  pcl_ros
  roscpp
  sensor_msgs
  std_msgs
)

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)
find_package(PCL REQUIRED)
find_package(OpenCV 2.4.8 REQUIRED COMPONENTS highgui imgproc)
# Do NOT use OpenCV 3.0.0 or all hell will break loose. Package incompatilibity will be a fascinating thing to deal with...

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
 INCLUDE_DIRS include
#  LIBRARIES pmd_nano
 CATKIN_DEPENDS cv_bridge image_transport pcl_conversions pcl_msgs pcl_ros roscpp sensor_msgs std_msgs uvc_camera
 DEPENDS
   system_lib # Boost PCL OpenCV
   boost_system
   PCL
   opencv_highgui opencv_imgproc
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

## Declare a cpp library
# add_library(pmd_nano
#   src/${PROJECT_NAME}/pmd_nano_node.cpp
# )

## Declare a cpp executable
add_executable(pmd_nano_node
    src/pmd_nano_node.cpp
    src/ColorCamera.cpp
    src/DepthCamera.cpp
    src/PMDNano.cpp
)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
# add_dependencies(pmd_nano_node pmd_nano_generate_messages_cpp)

## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES})
#link_directories(${PROJECT_NAME}_node ${Boost_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME}_node boost_system)
link_directories(${PROJECT_NAME}_node ${PCL_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME}_node opencv_highgui opencv_imgproc)
target_link_libraries(${PROJECT_NAME}_node pthread)

target_link_libraries(pmd_nano_node ${PROJECT_SOURCE_DIR}/lib/libpmdaccess2.so)


#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_pmd_nano.cpp)
# if(TARGET ${PROJECT_NAME}-test)
#   target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)

编辑:

运行 sudo updatedb 至少解决了 locate 问题。 运行 期间的错误仍然存​​在。

找到解决方案。由于删除了包,我的工作区似乎一团糟。因此,在我删除 develbuild 之后快速 catkin_make 它现在运行良好.