cannot find -lopencv_imgcodecs

在编译caffe时出现错误:

/usr/bin/ld: cannot find -lopencv_imgcodecs

为了改正错误尝试修改Makefile.config文件:

LIBRARIES+= glog gflags protobuf leveldb snappy lmdbboost_system hdf5_hl hdf5 m 
opencv_coreopencv_highgui opencv_imgproc opencv_imgcodecs

改为上面的形式可是编译时还是报错。

检查opencv编译生成的链接库,因为电脑里已经安装了opencv2且安装默认的/usr/local文件夹下,所以安装opencv3时设置安装在/usr/local/opencv3目录下。

安装完成后要修改~/.bashrc文件并添加下面两行:

 export PKG_CONFIG_PATH=/usr/local/opencv320/lib/pkgconfig  
 export LD_LIBRARY_PATH=/usr/local/opencv320/lib  

保存后执行:

source ~/.bashrc 

经过分析上面的错误可能是caffe编译时调用的是opencv2而不是opencv3造成的,所以再次修改Makefile.config:

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/opencv3/include /usr/local/include /usr/include/hdf5/serial 
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/opencv3/lib /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial 

将opencv3编译后的路径加到前面。

你可能感兴趣的:(深度学习)