ROS,opencv3和CMake-无法删除库 [英] ROS, opencv3 and CMake - unable to remove the library

查看:94
本文介绍了ROS,opencv3和CMake-无法删除库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

工作环境:

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

出于某些未知的原因,我决定安装 ros-indigo-opencv3 软件包,由于我也有Ubuntu 14.04-OpenCV 2.4.8随附的默认版本,对此我几乎立即感到后悔.

For some unknown reason I decided to install the ros-indigo-opencv3 package which I regretted almost immediately due to the fact I also have the default version that comes with Ubuntu 14.04 - OpenCV 2.4.8.

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

At first I noticed that QtCreator was warning me of possible incompatibility between 2.4.8 and 3.0.0 when I was building my CMake project (you can see the CMakeLists.txt at the end of this post) using only

find_package(OpenCV REQUIRED)

然后,错误开始在cv :: stereoSGBM模块周围丢失了一些参考.命名空间或其他内容似乎有所变化,我使用的库使用OpenCV的2.x分支(发现困难的方式显然是:D),所以我告诉自己-我想我将删除上述ROS包OpenCV 3.0.0并坚持使用2.4.8.

Then the errors started flowing about some missing reference around the cv::stereoSGBM module. There seems to be some change in the namespaces or whatever and the library I am using uses the 2.x branch of OpenCV (found that the hard way obviously :D) hence I told myself - I guess I will remove the above mentioned ROS package for OpenCV 3.0.0 and stick with the 2.4.8.

卸载该软件包后,所有的东西都变成了香蕉.即使在我项目的CMakeLists.txt中,我也明确指出了版本2.4.8.被使用

After uninstalling that package it all went bananas. Even though in CMakeLists.txt of my project I explicitly pointed version 2.4.8. to be used

find_package(OpenCV 2.4.8 REQUIRED)

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

upon launching my node with roslaunch died immediately with the following error:

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

.../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传递结果

Huh...Okay...I checked if something has been left on my system (bad package maybe, which was unable to install and accordingly install properly?). For my surprise upon calling locate and piping the result with 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.

So something was left there after all (with something I mean everything :D). However imagine my surprise when I cd-ed to the /opt/ros/indigo/lib/ and found NOT A SINGLE file even remotely related to OpenCV let alone OpenCV 3.0.0.

使用 pkg-config 至少返回我期望的结果:

Using pkg-config returns what I am expecting at least:

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作为参数)

Note: I still don't know why --cflags never shows the opencv2 include folder (opencv2 as argument is not recognized by pkg-config)

进一步的调查使我需要以 3.0.0 版本重新运行项目的CMakeLists.txt,实际上CMake现在抱怨只有 2.4.8 成立.出于什么原因,尽管该应用程序试图获取OpenCV共享库的3.0.0版本,仍然有待观察.

Further investigation made me re-run my CMakeLists.txt for my project with the 3.0.0 version as requirement and indeed CMake now complains that only 2.4.8 is found. For what reason though the application tries to get the 3.0.0 version of OpenCV's shared libs remains to be seen.

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

Any advice or someone who has encountered such problem before?

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更新b 至少解决了 locate 问题.但是,运行时错误仍然存​​在.

Running sudo updatedb at least resolved the locate issue. The error during runtime is still present though.

推荐答案

找到了解决方案.由于删除了程序包,我的工作区似乎一团糟.因此,在删除 devel build 之后,再执行快速的 catkin_make 后,它现在可以正常运行了.

Found the solution. It seemed that my workspace was a mess because of the removal of the package. So after I deleted devel and build followed by a quick catkin_make it runs fine now.

这篇关于ROS,opencv3和CMake-无法删除库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆