caffe安装:opencv libpng16.so.16链接问题 [英] caffe installation : opencv libpng16.so.16 linkage issues

查看:132
本文介绍了caffe安装:opencv libpng16.so.16链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ubuntu 14.04计算机上使用python接口编译caffe.

I am trying to compile caffe with python interface on an Ubuntu 14.04 machine.

我已经用conda install opencv安装了Anaconda和opencv.我还安装了咖啡中规定的所有要求,并更改了makefile.config中的注释框,以便PYTHON_LIB和PYTHON_INCLUDE指向Anaconda发行版.

I have installed Anaconda and opencv with conda install opencv. I have also installed all the requirement stipulated in the coffee and changed the commentary blocks in makefile.config so that PYTHON_LIB and PYTHON_INCLUDE point towards Anaconda distributions.

当我呼叫make all时,将发出以下命令:

When I am calling make all, the following command is issued:

g++ .build_release/tools/caffe.o -o .build_release/tools/caffe.bin -pthread 
-fPIC -DNDEBUG -O2 -DWITH_PYTHON_LAYER 
-I/home/andrei/anaconda/include 
-I/home/andrei/anaconda/include/python2.7 
-I/home/andrei/anaconda/lib/python2.7/site-packages/numpy/core/include
-I/usr/local/include 
-I/home/andrei/anaconda/lib 
-I/lib/x86_64-linux-gnu 
-I/lib64 
-I/usr/lib/x86_64-linux-gnu 
-I.build_release/src 
-I./src 
-I./include 
-I/usr/include 
-Wall -Wno-sign-compare -lcaffe 
-L/home/andrei/anaconda/lib 
-L/home/andrei/anaconda/lib/././ 
-L/usr/local/lib -L/usr/lib 
-L/home/andrei/anaconda/lib/././libpng16.so.16 
-L/lib/x86_64-linux-gnu 
-L/lib64 
-L/usr/lib/x86_64-linux-gnu 
-L/usr/lib 
-L.build_release/lib  
-lcudart -lcublas -lcurand -lglog -lgflags -lprotobuf -lleveldb -lsnappy 
-llmdb -lboost_system -lhdf5_hl -lhdf5 -lm 
-lopencv_core -lopencv_highgui -lopencv_imgproc -lboost_thread -lstdc++ 
-lboost_python -lpython2.7 -lcblas -latlas \
-Wl,-rpath,\$ORIGIN/../lib

但是,它会因以下错误而停止:

However, it is stopped by the following set of errors:

/usr/bin/ld: warning: libpng16.so.16, needed by /home/andrei/anaconda/lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_read_struct@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_interlace_handling@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_IHDR@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_io_ptr@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_longjmp_fn@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_gray_to_rgb@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_compression_level@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_bgr@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_filter@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_rgb_to_gray@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_init_io@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_destroy_read_struct@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_swap@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_IHDR@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_palette_to_rgb@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_compression_strategy@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_tRNS@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_info@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_packing@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_read_fn@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_info_struct@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_end@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_update_info@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_image@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_end@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_expand_gray_1_2_4_to_8@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_write_struct@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_image@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_info@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_strip_alpha@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_write_fn@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_destroy_write_struct@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_error@PNG16_0'
/home/andrei/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_strip_16@PNG16_0'

遵循此问题的建议:

Following the advice from this question: Caffe install on ubuntu for anaconda with python 2.7 fails with libpng16.so.16 not found, I tired running the ldd /home/andrei/anaconda/lib/libopencv_highgui, and obtained the following output:

linux-vdso.so.1 =>  (0x00007fff1a104000)
    libopencv_core.so.2.4 => /home/andrei/anaconda/lib/././libopencv_core.so.2.4 (0x00007ff18e8a0000)
    libopencv_imgproc.so.2.4 => /home/andrei/anaconda/lib/././libopencv_imgproc.so.2.4 (0x00007ff18e3f0000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff18e1ec000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff18dfce000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ff18ddc6000)
    libz.so.1 => /home/andrei/anaconda/lib/././libz.so.1 (0x00007ff18dbb0000)
    libjpeg.so.8 => /home/andrei/anaconda/lib/././libjpeg.so.8 (0x00007ff18d979000)
    libpng16.so.16 => /home/andrei/anaconda/lib/././libpng16.so.16 (0x00007ff18d737000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007ff18d535000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007ff18d22d000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff18cf29000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff18cc23000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff18ca0d000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff18c648000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff18f0d0000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007ff18c40a000)

然后我继续将所有必需的目录添加到make.config文件的INCLUDE_DIRSLIBRARY_DIRS中(因此,在上面的g++调用中还有其他的-I-L),包括显式链接anaconda库中已经存在的libpng16.so.16.但是,这尚未解决问题.我还尝试将文件添加到$LD_LIBRARY_PATH$LD_RUN_PATH,但是没有任何效果.

I then proceeded to add all the required directories into the INCLUDE_DIRS and LIBRARY_DIRS of the make.config file (hence additional -I and -L in the g++ call above), including the explicit link to libpng16.so.16 already present in anaconda libraries. This have however not resolved the issue. I also tried adding the file to $LD_LIBRARY_PATH and $LD_RUN_PATH, but without any effect.

可能是什么问题,我该如何解决?

What might the problem be and how could I resolve it?

推荐答案

我遇到了同样的问题.我发现它与 https://github.com/BVLC/caffe/issues/2007 类似,并且我解决了通过

I came across the same problem. I found it similar to https://github.com/BVLC/caffe/issues/2007, and I solved it by

cd /usr/lib/x86_64-linux-gnu
sudo ln -s ~/anaconda/lib/libpng16.so.16 libpng16.so.16
sudo ldconfig

这篇关于caffe安装:opencv libpng16.so.16链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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