caffe安装:opencv libpng16.so.16连接问题

时间:2015-09-04 19:09:21

标签: python opencv ubuntu anaconda caffe

我正在尝试在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)

然后我继续将所有必需的目录添加到INCLUDE_DIRS文件的LIBRARY_DIRSmake.config中(因此-I-L中的其他g++libpng16.so.16 {1}}上面调用),包括已经存在于anaconda库中的$LD_LIBRARY_PATH的显式链接。然而,这并未解决问题。我还尝试将文件添加到$LD_RUN_PATH/,但没有任何影响。

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

2 个答案:

答案 0 :(得分:4)

根据此处https://github.com/hashdist/hashstack/issues/670

的解决方案,它与我合作
if (!roomInfo.isVisited()) {
  roomInfo.setVisited(true);
  applyEvents(roomInfo.getEvents());
}

这应添加到export LD_LIBRARY_PATH=~/anaconda2/lib:$LD_LIBRARY_PATH ~/.bashrc

答案 1 :(得分:-1)

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

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