1、安装cmake
1.1 下载cmake
在 https://cmake.org/download/ 网址下载 cmake-3.9.5.tar.gz
1.2 解压cmake
tar xvf cmake-3.9.5.tar.gz 或者在安装包上点击解压到此处
1.3 安装cmake
cd cmake-3.9.5
./bootstrap
sudo make
sudo make install
2、安装opencv
2.1 下载opencv
在 https://opencv.org/releases.html 下载 opencv-2.4.13.3.zip
2.1 解压opencv
unzip -d ./ opencv-2.4.13.3.zip 或者点击右键解压到此处
2.2 安装opencv
cd opencv-2.4.13.3
mkdir build
cd build
cmake .. //注意有两个点
sudo make -j 10
sudo make install
3、 注意事项
非root账户添加sudo
如果执行 cmake时候出现如下错误信息
Shell
CMake Error at CMakeLists.txt:11 (message):
FATAL: In-source builds are not allowed.
You should create separate directory for build files.
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!
Shell
CMake Error at CMakeLists.txt:11 (message):
FATAL: In-source builds are not allowed.
You should create separate directory for build files.
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再次执行编译即可。
Ubuntu 16.04编译安装过程同上。