ROS,opencv3和CMake - 无法删除库

时间:2015-08-01 14:28:43

标签: c++ opencv cmake ros opencv3.0

工作环境:

  • Kubuntu 14.04 LTS 64bit
  • ROS Indigo(最新的完整桌面安装)
  • OpenCV 2.4.8

由于某些未知原因,我决定安装 ros-indigo-opencv3 软件包,由于我还拥有Ubuntu 14.04附带的默认版本 - OpenCV 2.4.8,我几乎立即后悔了。

起初我注意到QtCreator警告我,当我构建我的CMake项目时,2.4.8和3.0.0之间可能存在不兼容性(你可以在本帖末尾看到CMakeLists.txt)仅使用

find_package(OpenCV REQUIRED)

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

卸载该包后,所有都去了香蕉。即使在我项目的CMakeLists.txt中,我明确指出了2.4.8版本。待用

find_package(OpenCV 2.4.8 REQUIRED)

启动我的节点时,roslaunch立即死亡,并出现以下错误:

  

... / pmd_nano_node:加载共享库时出错: libopencv_highgui.so.3.0 :无法打开共享对象文件:没有这样的文件或目录

嗯......好吧......我检查了我的系统上是否还有什么东西(可能包装不好,无法安装并相应安装?)。在调用 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 / 并发现NOT A SINGLE文件甚至远程与OpenCV相关时更让人惊讶,更不用说OpenCV 3.0了。 0

使用 pkg-config 返回我至少期待的内容:

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 包含文件夹(pkg-config无法识别opencv2作为参数)< / p>

进一步的调查使我重新运行我的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 至少解决了定位问题。运行期间的错误仍然存​​在。

1 个答案:

答案 0 :(得分:2)

找到解决方案。由于拆除包裹,我的工作空间似乎很乱。因此,在我删除 devel 构建,然后快速 catkin_make 之后,它现在运行良好。