WARNING ** io features related to openni2 pcap png will be disabled

小咪咪 2021-11-29 15:08 394阅读 0赞

0. 写在最前面

本文持续更新地址:https://haoqchen.site/2019/07/22/pcl-openni2/

如果觉得写得还不错,可以找我其他文章来看看哦~~~可以的话帮我github点个赞呗。

你的Star是作者坚持下去的最大动力哦~~~

1. 问题描述

使用PCL编译某个ROS工程时出现这个waring:

  1. ** WARNING ** io features related to openni2 will be disabled
  2. ** WARNING ** io features related to pcap will be disabled
  3. ** WARNING ** io features related to png will be disabled
  4. ** WARNING ** visualization features related to openni2 will be disabled

这里其实是3个东西缺了

2. 解决办法

2.1 OpenNI2问题

找到对应log文件后发现是OpenNI没有

  1. Could NOT find OpenNI2 (missing: OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS)

所以就安装OpenNI就好:

  1. sudo apt-get install openni2-utils

2.2 png问题

png的问题是由于pcl的cmake文件缺了相关的查找。我装ROS的时候已经默认装了libpng,如果你增加了下面这两句还是有问题,可以考虑装一个这个,但千万要小心,我更新了libpng之后不小心把ROS的东西删了,又得重装一下。

/usr/lib/x86_64-linux-gnu/cmake/pcl目录下找到PCLConfig.cmake文件,用sudo gedit PCLConfig.cmake,在466行后面(find_openni2()下面)增加这句话:

  1. elseif("${_lib}" STREQUAL "png")
  2. find_package(PNG)

2.3 pcap问题

理由同上,不过libpcap这个是网络抓取包,一般系统不会帮忙装,需要自己装:

  1. sudo apt-get install libpcap-dev

装完之后在PCLConfig.cmake中添加下面这两句:

  1. elseif("${_lib}" STREQUAL "pcap")
  2. find_package(PCAP)

这个时候还不行,貌似是因为libpcap在安装的时候不会自己配置cmake。。。。。需要你到cmake的Modules目录下,我的是/usr/share/cmake-3.5/Modules,每个人不一样,里面会有很多的Findxxx.cmake的文件。你需要新建一个FindPCAP.cmake,然后往里面填入以下的内容(这部分来源于这位老哥的github)

  1. # - Try to find libpcap include dirs and libraries
  2. #
  3. # Usage of this module as follows:
  4. #
  5. # find_package(PCAP)
  6. #
  7. # Variables used by this module, they can change the default behaviour and need
  8. # to be set before calling find_package:
  9. #
  10. # PCAP_ROOT_DIR Set this variable to the root installation of
  11. # libpcap if the module has problems finding the
  12. # proper installation path.
  13. #
  14. # Variables defined by this module:
  15. #
  16. # PCAP_FOUND System has libpcap, include and library dirs found
  17. # PCAP_INCLUDE_DIR The libpcap include directories.
  18. # PCAP_LIBRARY The libpcap library (possibly includes a thread
  19. # library e.g. required by pf_ring's libpcap)
  20. # HAVE_PF_RING If a found version of libpcap supports PF_RING
  21. # HAVE_PCAP_IMMEDIATE_MODE If the version of libpcap found supports immediate mode
  22. find_path(PCAP_ROOT_DIR
  23. NAMES include/pcap.h
  24. )
  25. find_path(PCAP_INCLUDE_DIR
  26. NAMES pcap.h
  27. HINTS ${PCAP_ROOT_DIR}/include
  28. )
  29. set (HINT_DIR ${PCAP_ROOT_DIR}/lib)
  30. # On x64 windows, we should look also for the .lib at /lib/x64/
  31. # as this is the default path for the WinPcap developer's pack
  32. if (${CMAKE_SIZEOF_VOID_P} EQUAL 8 AND WIN32)
  33. set (HINT_DIR ${PCAP_ROOT_DIR}/lib/x64/ ${HINT_DIR})
  34. endif ()
  35. find_library(PCAP_LIBRARY
  36. NAMES pcap wpcap
  37. HINTS ${HINT_DIR}
  38. )
  39. include(FindPackageHandleStandardArgs)
  40. find_package_handle_standard_args(PCAP DEFAULT_MSG
  41. PCAP_LIBRARY
  42. PCAP_INCLUDE_DIR
  43. )
  44. include(CheckCXXSourceCompiles)
  45. set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
  46. check_cxx_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
  47. set(CMAKE_REQUIRED_LIBRARIES)
  48. # check if linking against libpcap also needs to link against a thread library
  49. if (NOT PCAP_LINKS_SOLO)
  50. find_package(Threads)
  51. if (THREADS_FOUND)
  52. set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
  53. check_cxx_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS)
  54. set(CMAKE_REQUIRED_LIBRARIES)
  55. endif (THREADS_FOUND)
  56. if (THREADS_FOUND AND PCAP_NEEDS_THREADS)
  57. set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
  58. list(REMOVE_DUPLICATES _tmp)
  59. set(PCAP_LIBRARY ${_tmp}
  60. CACHE STRING "Libraries needed to link against libpcap" FORCE)
  61. else (THREADS_FOUND AND PCAP_NEEDS_THREADS)
  62. message(FATAL_ERROR "Couldn't determine how to link against libpcap")
  63. endif (THREADS_FOUND AND PCAP_NEEDS_THREADS)
  64. endif (NOT PCAP_LINKS_SOLO)
  65. include(CheckFunctionExists)
  66. set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
  67. check_function_exists(pcap_get_pfring_id HAVE_PF_RING)
  68. check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE)
  69. check_function_exists(pcap_set_tstamp_precision HAVE_PCAP_TIMESTAMP_PRECISION)
  70. set(CMAKE_REQUIRED_LIBRARIES)
  71. mark_as_advanced(
  72. PCAP_ROOT_DIR
  73. PCAP_INCLUDE_DIR
  74. PCAP_LIBRARY
  75. )

删除下缓存重新编译就完美解决拉

参考

  • https://github.com/PointCloudLibrary/pcl/issues/2651

喜欢我的文章的话Star一下呗Star

版权声明:本文为白夜行的狼原创文章,未经允许不得以任何形式转载

发表评论

表情:
评论列表 (有 0 条评论,394人围观)

还没有评论,来说两句吧...

相关阅读