-
编译环境安装:
1sudo
apt-get
install
build-essential
2. 必需包安装:
1sudo
apt-get
install
cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
3.可选包安装:
1sudo
apt-get
install
python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
-
下载opencv3.1
wget https://github.com/Itseez/opencv/archive/3.1.0.zip
-
下载完了 放在 /usr/local
用 unzip 解压刚才下载文件
-
进入opencv-3.1.0
创建build
-
进入 build
接下来 就开始干
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
-
make -j7 $(nproc)
和
make install
-
/bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig(这一步很重要)
8. sudo gedit /etc/ld.so.conf.d/opencv.conf
输入库文件路径,保存并退出 /usr/local/lib sudo ldconfig
9.设置环境变量
sudo gedit /etc/bash.bashrc
在最后加入以下两行代码
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
-
pkg-config --modversion opencv
pkg-config --cflags opencv