opencv arm 编译静态库

1.首先下载opencv

通过脚本:https://github.com/azuredsky/Install-OpenCV

2.安装cmake ,arm 交叉编译工具

3.开始camke

选择Unix Makefiles -> Specify options for cross-compiling

opencv arm 编译静态库_第1张图片

2.配置arm compilers

Target System:

Operating System :Linux

Version: 3.4.3

Processor:arm

Compilers:

C:/opt/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc  (arm gcc 编译器)

C++:/opt/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ (arm g++ 编译器)

Find Program/Library/include:

Target Root: /opt/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu (arm 编译器目录)

opencv arm 编译静态库_第2张图片

3.选择编译事项

设置安装目录:CMAKE_INSTALL_PREFIX: /usr/local/arm-opencv

取消以下勾选:

BUILD_PNG

BUILD_JPEG

BUILD_SHARED_LIBS(这里我们要编译静态库)

关闭以下选项,设为False

WITH_1394
WITH_CUDA
WITH_CUFFT X
WITH_EIGEN
WITH_GSTREAMER
WITH_GTK
WITH_JASPER
WITH_JPEG
WITH_OPENEXR
WITH_PNG
WITH_PVAPI
WITH_QT
WITH_TBB
WITH_TIFF
WITH_UNICAP X
WITH_V4L
WITH_XINE

WITH_EIGEN
WITH_IPP
BUILD_ZLIB
BUILD_opencv_gapi
BUILD_IPP_IW

删除不需要的host库

-delete ZLIB_INCLUDE_DIR

-delete ZLIB_LIBRARY_PATH

4.开始编译

make -j6

sudo make install

5.开发工程添加链接

注意:在链接静态库时请务必将libzlib.a 放在最后一项链接(否则会报以下错误:

persistence.cpp:(.text.cvOpenFileStorage+0x66e): undefined reference to `gzopen'
persistence.cpp:(.text.cvOpenFileStorage+0x8fc): undefined reference to `gzclose'
persistence.cpp:(.text.cvOpenFileStorage+0xaea): undefined reference to `gzrewind'
persistence.cpp:(.text.cvOpenFileStorage+0xbee): undefined reference to `gzrewind'
persistence.cpp:(.text.cvOpenFileStorage+0xc0a): undefined reference to `gzclose'

 

6.如果在cmake 中出现问题參考:https://blog.csdn.net/qq2010899751/article/details/82533262

我在编译中出现NEON 问题:

undefined reference to `png_init_filter_functions_neon'
        修改:opencv-3.4.3/3rdparty/libpng/CMakeLists.txt

添加以下两行
        set(ENABLE_NEON ON)
        set(AARCH64 ON)
 

你可能感兴趣的:(arm,opencv)