美文网首页
2018-11-14编译Guidance-SDK-ROS包出错

2018-11-14编译Guidance-SDK-ROS包出错

作者: 我爱做笔记 | 来源:发表于2018-11-14 19:23 被阅读0次

参考链接:https://github.com/dji-sdk/Guidance-SDK-ROS
将Guidance-SDK-ROS 包拷贝进我的工作空间后使用catkin_make进行编译,出错如下:

CMakeFiles/guidanceNodeCalibration.dir/src/GuidanceNodeCalibration.cpp.o: In function `my_callback(int, int, char*)':
GuidanceNodeCalibration.cpp:(.text+0x9a4): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
GuidanceNodeCalibration.cpp:(.text+0xb9b): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
GuidanceNodeCalibration.cpp:(.text+0xddc): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
collect2: error: ld returned 1 exit status
Guidance-SDK-ROS/CMakeFiles/guidanceNodeCalibration.dir/build.make:145: recipe for target '/home/cyril/Disk/ros_robotics_projects_ws/devel/lib/guidance/guidanceNodeCalibration' failed
make[2]: *** [/home/Disk/ros_robotics_projects_ws/devel/lib/guidance/guidanceNodeCalibration] Error 1
CMakeFiles/Makefile2:447: recipe for target 'Guidance-SDK-ROS/CMakeFiles/guidanceNodeCalibration.dir/all' failed
make[1]: *** [Guidance-SDK-ROS/CMakeFiles/guidanceNodeCalibration.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j2 -l2" failed

在Google上搜索过后基本没有找到明确的解决办法,但是能够确定的方向就是编译时没有正确链接到OpenCV的库。所以基本上要从OpenCV以及CMakelist的设置上来寻找答案了。
通过编译打印的日志:

-- +++ processing catkin package: 'guidance'
-- ==> add_subdirectory(Guidance-SDK-ROS)
System is: x86_64
-- 64bit detected
-- OpenCV library status:
--     version: 2.4.9.1
--     libraries: opencv_core;opencv_highgui
--     include path: /opt/ros/kinetic/include/opencv;/opt/ros/kinetic/include

可以看到我这里链接的OpenCV版本是2.4.9.1 ,然而通过查看OpenCV的版本:

pkg-config --modversion opencv
3.4.2

我的OpenCV是3.4.2 ,所以这里出问题的地方应该是链接OpenCV时冲突了,导致找不到对应的包了。
我们查看Guidance-SDK-ROS的CMakeList.txt文件:

cmake_minimum_required(VERSION 2.8.3)
project(guidance)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  cv_bridge
  std_msgs
  sensor_msgs
  geometry_msgs
)

find_package(OpenCV 2 REQUIRED core highgui)

catkin_package(
)

include_directories(
  ${OpenCV_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
  include
)

message("System is: " ${CMAKE_SYSTEM_PROCESSOR})
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  if (CMAKE_SIZEOF_VOID_P EQUAL 4)
    message("-- 32bit detected")
    link_directories(lib/x86)
  elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
    message("-- 64bit detected")
    link_directories(lib/x64)
  endif ()
else()
  message("-- Non-linux platform detected but sorry we do not support :D")
endif ()

if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l" )
  message("-- " ${CMAKE_SYSTEM_PROCESSOR} " detected")
  link_directories(lib/XU3)
else ()
endif ()

##cyril add the following
message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

link_libraries(
  ${OpenCV_LIBS}
  ${catkin_LIBRARIES}
  DJI_guidance
  usb-1.0
  yaml-cpp)

add_executable(guidanceNode
  src/GuidanceNode.cpp
  src/DJI_utility.cpp)

add_executable(guidanceNodeTest
  src/GuidanceNodeTest.cpp)

add_executable(guidanceNodeCalibration
  src/GuidanceNodeCalibration.cpp
  src/DJI_utility.cpp)

参考了这篇帖子: https://blog.csdn.net/u012816621/article/details/51732932
我在find_package这句话前面去设置opencv的OpenCV文件夹位置,我的ROS中也装有OpenCV的包,那么就将ROS中的这个文件夹路径加进去/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv 修改如下:

###下面的set就是自己添加的,然后将原来find_package中的OpenCV 2 改成OpenCV
set(OpenCV_DIR /opt/ros/kinetic/include/opencv-3.3.1-dev/opencv)
find_package(OpenCV  REQUIRED core highgui)

catkin_package(
)

include_directories(
  ${OpenCV_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
  include
)

重新在工作空间进行编译,就成功通过了!

相关文章

  • 2018-11-14编译Guidance-SDK-ROS包出错

    参考链接:https://github.com/dji-sdk/Guidance-SDK-ROS将Guidance...

  • Mac安装protobuf(安装包)

    下载安装包 编译 编译出错make[2]: *** [message.lo] Error 1make[1]: **...

  • 软件安装

    软件包分类:1.源码包需要经过编译,安装时间长,容易出错,新手难以解决可以定制安装功能2.二进制包(rpm包、系统...

  • docker centos 镜像 安装nginx

    安装方式:yum安装和源码包安装yum安装的好处:在线安装,不易出错源码包安装的好处是在自己系统编译安装的,性能更...

  • error: 'cout' was not declared i

    Linux下C++编译出错原因解析 程序: 编译出错:$ g++ s.cpp -o s.outs.cpp: In ...

  • AS编译出错

    好好的项目,突然编译运行不了了,整整弄了一天,经历过什么叫做“绝望”。。。。记录下这次“绝望”的经历 编译的时候,...

  • 编译出错

    查找错误关键字 Caused by Unable to find explicit activity class ...

  • 编译出错

    在清单application下添加以下代码就好了

  • Java 泛型反射与擦除

    问:下面两个代码片段有问题吗,为什么? 答:上面 Part 1 编译出错,Part 2 编译 OK,运行出错。因为...

  • react antd修改主题色

    出错原因:按照antd官网,修改主题色,本地使用css-module 类名重新编译,导致样式修改不成功。 依赖包及...

网友评论

      本文标题:2018-11-14编译Guidance-SDK-ROS包出错

      本文链接:https://www.haomeiwen.com/subject/auxsfqtx.html