ubuntu安装caffe:libopencv_core.so.3.4: error adding symbols: DSO missing from command line

caffe的安装方法参考此博客https://blog.csdn.net/A_Z666666/article/details/72853346

运行make all时报错:

~/caffe$ make all -j4
CXX/LD -o .build_release/examples/cpp_classification/classification.bin
/usr/bin/ld: warning: libopencv_core.so.3.4, needed by //usr/local/lib/x86_64-linux-gnu/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: .build_release/examples/cpp_classification/classification.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
//usr/local/lib/x86_64-linux-gnu/libopencv_core.so.3.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [.build_release/examples/cpp_classification/classification.bin] Error 1

可能原因:

1)没有创建libopencv_core.so.3.4的软链接

解决方法:

到opencv的安装路径下,复制libopencv_core.so,libopencv_core.so.3.4还有libopencv_core.so.3.4.4到/usr/local/lib/x86_64-linux-gnu

注意:因为我的版本是3.4.4,具体情况可能和版本号不同而不同,自己注意修改

我抛出来的错的路径是/usr/local/lib/x86_64-linux-gnu,这个路径也可能不同,自己注意修改

创建软连接:

$ sudo chmod +r libopencv_core.so.3.4.4  
$ sudo ln -sf libopencv_core.so.3.4.4 libopencv_core.so.3.4  
$ sudo ln -sf libopencv_core.so.3.4 libopencv_core.so  
$ sudo ldconfig

终端输入ll检测一下,出现以下链接说明成功,可以再make all尝试

lrwxrwxrwx 1 root root       21 11月 22 11:23 libopencv_core.so -> libopencv_core.so.3.4
lrwxrwxrwx 1 root root       23 11月 22 11:22 libopencv_core.so.3.4 -> libopencv_core.so.3.4.4
-rw-r--r-- 1 root root 19269952 11月 22 11:19 libopencv_core.so.3.4.4

2)Makefile.config中没有加路径

解决方法:直接添加

~/caffe$ sudo gedit Makefile.config

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/lib/x86_64-linux-gnu

保存退出,make all

我是做了以上两步才解决的

运行make runtime时报错:

$ make runtime -j4
.build_release/tools/caffe
.build_release/tools/caffe: error while loading shared libraries: libopencv_imgproc.so.3.4: cannot open shared object file: No such file or directory
make: *** [runtest] Error 127

 解决方法:在本地路径找到缺失的文件的地址,如果没找到,就从caffe安装地址复制过去,终端输入地址

sudo ldconfig /usr/local/lib/x86_64-linux-gnu

后续安装TensorFlow1.6.0报错:

$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/schidester/usr/tf/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in 
    from tensorflow.python import *
  File "/home/schidester/usr/tf/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 75, in 
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/schidester/usr/tf/local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 9, in 
    from google.protobuf import symbol_database as _symbol_database
  File "/usr/local/lib/python2.7/dist-packages/google/protobuf/symbol_database.py", line 165, in 
    _DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
AttributeError: 'module' object has no attribute 'Default'

原因:protobuf版本原因

1、确认自己的protobuf版本是否匹配,我是tf1.6.0,需要对应3.4.0以上版本,我就安装了protobuf3.4.0

2、在/usr/lib/python2.7中查找一下有没有安装protobuf2,就直接搜索,然后全部手动删除

自己pip安装的protobuf3是在/usr/local/lib/python2.7/dist-packages中,因此会出现版本有冲突

参考这个回复

你可能感兴趣的:(原创,环境配置)