【问题标题】:caffe installation : opencv libpng16.so.16 linkage issuescaffe 安装:opencv libpng16.so.16 链接问题
【发布时间】:2015-09-04 19:09:21
【问题描述】:

我正在尝试在 Ubuntu 14.04 机器上使用 python 接口编译 caffe。

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

当我打电话给make all时,会发出以下命令:

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

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

/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'

按照这个问题的建议:Caffe install on ubuntu for anaconda with python 2.7 fails with libpng16.so.16 not found,我厌倦了运行ldd /home/andrei/anaconda/lib/libopencv_highgui,并获得以下输出:

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),包括显式链接libpng16.so.16 已经存在于 anaconda 库中。然而,这并没有解决问题。我也尝试将文件添加到$LD_LIBRARY_PATH$LD_RUN_PATH,但没有任何效果。

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

【问题讨论】:

  • 你能把你的 make.config 粘贴到其他任何地方的 pastebin 上吗?
  • 你和我的 makefile.config 的区别:我使用 BLAS:=open 在 python_include 中我也有 $(ANACONDA_HOME)/lib。试试换东西?我能够使用我的 makefile 进行构建:pastebin.ru/MNM2N0FC

标签: python opencv ubuntu anaconda caffe


【解决方案1】:

我遇到了同样的问题。我发现它类似于https://github.com/BVLC/caffe/issues/2007,我解决了它

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

【讨论】:

  • @yangjie:你能解释一下这里发生了什么吗?
【解决方案2】:

它适用于我这里的解决方案https://github.com/hashdist/hashstack/issues/670

export LD_LIBRARY_PATH=~/anaconda2/lib:$LD_LIBRARY_PATH

应在~/.bashrc~/.bash_profile中添加

【讨论】:

  • 应该是export LD_LIBRARY_PATH=~/anaconda2/lib:$LD_LIBRARY_PATH=之间没有空格
【解决方案3】:

我猜你已经将/home/andrei/anaconda/bin 添加到PATH 环境变量中,以便libpng-config 解析为/home/andrei/anaconda/bin/libpng16-config,这就是导致cmake 尝试与libpng v1.6 链接的原因.

PATH 环境变量中删除anaconda 目录,libpng-config 应默认为/usr/lib 中的libpng v1.2 或类似内容。

【讨论】:

  • 不,显然问题出在其他地方。从 PATH 中删除 Anaconda 并没有真正起作用。除此之外,我正在尝试针对 Python 和 openCV 的 anaconda 版本显式编译 caffe,因此它想要使用已包含在 Anaconda PATH 中的 libpng16.so.16 是正常的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 2015-09-27
  • 2015-05-30
  • 1970-01-01
相关资源
最近更新 更多