Linux OpenCV cross compilation 20220322

Embedded development board development record


foreword

OpenCV cross-compilation records, it is also possible to compile directly on the development board, but the development board is easy to nospace, and the compilation speed is not fast, so choose cross-compilation.
Local platform: Ubuntu18.04
Target platform: Feiling Embedded
OpenCV version: 3.X

1. Preparation before compilation

1. Install Cmake

sudo apt-get install cmake  # 3.10版本

To install a specific version use the following methods:

1. sudo apt-get autoremove cmake  #卸载已安装的cmake
2. 在官网下载你需要的cmake版本:cmake官网下载:https://cmake.org/download/
3. 解压文件夹。以cmake-3.19.8为例,解压后是一个文件夹:cmake-3.19.8-Linux-x86_64
4. sudo mv cmake-3.19.8-Linux-x86_64 /opt/cmake-3.19.8
5. # 建立软链接
sudo ln -sf /opt/cmake-3.19.80/bin/*  /usr/bin/
6. # 查看 cmake 版本
cmake --version  #能够输出cmake版本说明安装成功

2. Install the cross compilation tool

Feiling Embedded has its own compilation tool, which does not need to be installed again. If the target platform does not have a compilation tool, it needs to be installed by itself.

Two, cmake-gui configuration

1. Selection of compilation tools

>>>cmake-gui   #终端输入启动cmake-gui界面

The step-by-step operation is as shown in the figure below
insert image description here
insert image description here
insert image description here
. As shown in the figure above, the cross-compilation tool comes with Feiling Embedded, just select the corresponding path.
If not, we have to download the cross-compilation tool corresponding to the target platform (such as aarch64, armv8, etc.).

1. Compile configuration generation

As shown in the figure below, select the opencv library installation path, and the compiled lib, include, and bin are in this directory.
insert image description here

insert image description here
1. Click Configure first. If an error occurs, uncheck all WITH_xxx above.
2. Then click Generate. The following figure appears to indicate success
insert image description here

3. Start compiling

1.make

Open the terminal and enter the compilation directory (the one selected in the second step of the compilation directory)
and enter the command: sudo make -j4 # -j4 means to use 4 cores for compilation
insert image description here

2. Error resolution

insert image description here
Open CmakeCache.txt, make the following modifications, add -pthread -lrt -ldl
insert image description here
other errors, search online, there should be solutions.
Re-execute the command: sudo make -j4 # Wait for more than ten minutes and reach 100% without error,
then execute the command: sudo make install

Summarize

The above is the complete OpenCV cross compilation process. The key point is to ensure that the selection is correct in the previous cross-compilation tool path, and the compilation will be successful.

Guess you like

Origin blog.csdn.net/zengwubbb/article/details/123958420
Recommended