1、获取源代码
git clone https://github.com/opencv/opencv.git
2、安装依赖库
sudo apt-get install -y cmake
3、编译源代码
cd opencv
mkdir build
cd build
cmake ..
make -j 10
4、编译出错的处理
CMake Error at CMakeLists.txt:11 (message):
FATAL: In-source builds are not allowed.
You should create separate directory for build files.
-- Configuring incomplete, errors occurred!
则应该是在代码根目录下直接执行过cmake,导致根目录下生成了CMakeCache.txt,需要删除CMakeCache.txt再次执行编译即可。