warning: libopencv_imgcodecs.so.3.2, needed by /...warning: libpng12.so.0, needed by /usr/local/lib/

warning: libopencv_imgcodecs.so.3.2, needed by /opt/ros/melodic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.3.3

usr/bin/ld: warning: libpng12.so.0, needed by /usr/local/lib/libopencv_imgcodecs.so.3.3.1, not found (try using -rpath or -rpath-link)

第一个错误是由于OpenCV和ros的图片格式不同引起的。
图片格式的转换需要OpenCV_bridge插件,解决办法是下载CV_bridge软件包,编译程序的时候连同插件一起编译。
https://www.cnblogs.com/cv-pr/p/5366764.html
可以参考这个https://www.cnblogs.com/yepeichu/p/10896201.html

第二个错误是缺少libpng12.so.0引起的。我直接下载一个放到对应文件夹里https://blog.csdn.net/qq_26413249/article/details/91442549?utm_medium=distribute.pc_relevant.none-task-blog-baidulandingword-5&spm=1001.2101.3001.4242
还有第二种思路就是下载libpng12-0,但是我没试过,因为我在/usr/lib/x86_64-linux-gnu/下面发现我有libpng16.so感觉这种方法只适合连libpng16.so都没有的情况,没试过,慎用https://blog.csdn.net/l_ricardo/article/details/82718241

bug描述

/usr/bin/ld: warning: libopencv_imgcodecs.so.3.2, needed by /opt/ros/melodic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.3.3
/usr/bin/ld: warning: libpng12.so.0, needed by /usr/local/lib/libopencv_imgcodecs.so.3.3.1, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_core.so.3.3, needed by /usr/local/lib/libopencv_imgcodecs.so.3.3.1, may conflict with libopencv_core.so.3.2
/usr/local/lib/libopencv_imgcodecs.so.3.3.1: undefined reference to png_get_IHDR@PNG12_0' /usr/local/lib/libopencv_imgcodecs.so.3.3.1: undefined reference to png_get_tRNS@PNG12_0’
/usr/local/lib/libopencv_imgcodecs.so.3.3.1: undefined reference to png_set_palette_to_rgb@PNG12_0'  /usr/local/lib/libopencv_imgcodecs.so.3.3.1: undefined reference to png_read_info@PNG12_0’
collect2: error: ld returned 1 exit status
ROS-Academy-for-Beginners/dependlib/hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/build.make:172: recipe for target ‘/home/cxl/catkin_ws/devel/lib/hector_compressed_map_transport/map_to_image_node’ failed
make[2]: *** [/home/cxl/catkin_ws/devel/lib/hector_compressed_map_transport/map_to_image_node] Error 1
CMakeFiles/Makefile2:5641: recipe for target ‘ROS-Academy-for-Beginners/dependlib/hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/all’ failed
make[1]: *** [ROS-Academy-for-Beginners/dependlib/hector_slam/hector_compressed_map_transport/CMakeFiles/map_to_image_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 96%] Built target gridfastslam
Makefile:140: recipe for target ‘all’ failed
make: *** [all] Error 2
Invoking “make -j12 -l12” failed

对于以下错误的解决

/usr/bin/ld: warning: libopencv_core.so.3.3, needed by /usr/local/lib/libopencv_highgui.so.3.3.1, may conflict with libopencv_core.so.3.2

  1. 在出现bug的ros工作空间中,下载新版本的cv_bridge:
cd catkin_ws/src
git clone https://github.com/ros-perception/vision_opencv.git

然后

cd ..
catkin_make --pkg cv_bridge

这时候再使用catkin_make在工作空间中编译原本的文件就可以了。

你可能感兴趣的:(ros,ubuntu)