1安装cmake以及依赖库
$ sudo apt-get install cmake
$ sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
2安装opencv(若下载的是OpenCV3.4.0版本)
$ tar -zxvf opencv-3.4.0.tar.gz
$ cd opencv-3.4.0
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler …
$ sudo make -j4
$ sudo make install
3.把opencv的so库加入到环境变量
$ sudo gedit /etc/ld.so.conf.d/opencv.conf //没有则新建
末尾加入/usr/local/lib,保存退出
$ sudo ldconfig #使配置生效
打开/etc/bash.bashrc;
$ sudo gedit /etc/bash.bashrc
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
加到文件末尾,保存退出
$ source /etc/bash.bashrc #使配置生效
$ sudo updatedb #更新database