1.在/home文件夹下面下载opencv
git clone https://github.com/opencv/opencv.git
2.进入文件夹opencv,并建立文件夹release
cd opencv
mkdir release
cd release
3.编译安装opencv
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
sudo make install
export LD_LIBRARY_PATH=~/opencv/release/lib:$LD_LIBRARY_PATH
sudo ldconfig
pkg-config opencv –libs
4.测试
进入文件夹opencv/samples/cpp/
cd ../sample/cpp/
g++ drawing.cpp -o drawing `pkg-config opencv --libs --cflags`
./drawing