本文介绍了在ubuntu上为蟒蛇2.7的Anaconda安装Caffe失败,找不到libpng16.so.16的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经使用python 2.7安装了anaconda并安装了Caffe库的所有要求.我确保通过以下方式安装opencv

So I have installed anaconda with python 2.7 and installed all of the requirements for Caffe library. I ensured that opencv is installed by

import cv2

并检查我是否可以运行文档中的几个示例.

And checking that I can run couple of examples from docs.

现在我下载caffe,正确配置makefile.config并运行make all.我收到一个很奇怪的错误:

Now I download caffe, configure makefile.config properly and run make all. I get very odd error:

make
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
/usr/bin/ld: warning: libpng16.so.16, needed by /home/maxkhk/anaconda/lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_read_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_interlace_handling@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_IHDR@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_io_ptr@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_longjmp_fn@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_gray_to_rgb@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_compression_level@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_bgr@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_filter@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_rgb_to_gray@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_init_io@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_destroy_read_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_swap@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_IHDR@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_palette_to_rgb@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_compression_strategy@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_tRNS@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_info@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_packing@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_read_fn@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_info_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_end@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_update_info@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_image@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_end@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_expand_gray_1_2_4_to_8@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_write_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_image@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_info@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_strip_alpha@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_write_fn@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_destroy_write_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_error@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_strip_16@PNG16_0'
collect2: error: ld returned 1 exit status
Makefile:560: recipe for target '.build_release/tools/upgrade_net_proto_text.bin' failed
make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1

那个家伙怎么了?请注意,我最初有anaconda3并为此编译了caffe,但成功了,但是在python3下我遇到了很多关于caffe的问题,因此我不得不将其删除并尝试将其设置为使用python 2.7的anaconda.

What's wrong with that guy? Notice that I originally had anaconda3 and compiled caffe for it but successfully but I faced tons of issues with caffe under python3, so I had to remove it and try to set it up for anaconda with python 2.7.

当然,我已经确保libpng16.so.16在anaconda中:

And of course I have ensured that libpng16.so.16 is in anaconda:

maxkhk@maxkhk-X550DP:~/anaconda$ find -name libpng16.so.16
./pkgs/libpng-1.6.17-0/lib/libpng16.so.16
./lib/libpng16.so.16
maxkhk@maxkhk-X550DP:~/anaconda$ 

我搜索了该错误,但未发现与咖啡有关的任何内容.

I googled the error, but haven't found anything in relation to caffe.

推荐答案

每个@cel建议-

ldd libopencv_highgui.so 

显示此库所依赖的文件.其中几个(不是libpng!)位于我没有包含在makefile.config中的文件夹中.将他们的文件夹包含到MakeFile中之后,构建成功.注意:构建caffe之后,您可能将不会进入Spyder到PythonPath管理器中并将caffe的文件夹添加到其中(或者,如果不使用anaconda \ spyder,则将其包含在pythonpath中).

shows the files on which this lib depends. Couple of them (not the libpng!) were located in folder which I haven't included into the makefile.config. After including their folder into MakeFile build succeeded. Notice: after building the caffe you may won't to go in Spyder into the PythonPath manager and add the caffe's folder into it (or just include it into pythonpath if you are not using anaconda\spyder).

这篇关于在ubuntu上为蟒蛇2.7的Anaconda安装Caffe失败,找不到libpng16.so.16的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 20:52