NDK+MSYS2+Android sdk编译opencv源码

由于今天太晚了,详细笔记有空再记。

 

    要添加的有ANDROID_ABI,这个根据需求添加自己需要的ABI

    

    然后是ANDROID_STL,因为gunstl已经不被支持,这里使用c++_shared或c++_static都可以。

 

   然后是ANDROID_STL,因为gunstl已经不被支持,这里使用c++_shared或c++_static都可以。

    

 

 

    添加完后点击“Configure”按钮,选择mingw作为生成工具,然后选择使用工具链交叉编译,点击“Next”。

 D:\android-ndk-r17c\build\cmake\android.toolchain.cmake

 

 

 

 

指定CMAKE_MAKE_PROGRAM

C:/msys64/mingw64/bin/mingw32-make.exe

 

 

 

 

 

 

 

 

输出配置信息:

 

General configuration for OpenCV 3.4.9 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2020-04-01T14:38:54Z
    Host:                        Windows 10.0.18363 AMD64
    Target:                      Android 1 aarch64
    CMake:                       3.16.0
    CMake generator:             MinGW Makefiles
    CMake build tool:            C:/msys64/mingw64/bin/mingw32-make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    NEON FP16
      required:                  NEON
      disabled:                  VFPV3

  C/C++:
    Built as dynamic libs?:      NO
    C++11:                       YES
    C++ Compiler:                D:/android-ndk-r17c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe  (ver 3.8)
    C++ flags (Release):         -isystem D:/android-ndk-r17c/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG   -DNDEBUG
    C++ flags (Debug):           -isystem D:/android-ndk-r17c/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info   -DDEBUG -D_DEBUG
    C Compiler:                  D:/android-ndk-r17c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
    C flags (Release):           -isystem D:/android-ndk-r17c/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG   -DNDEBUG
    C flags (Debug):             -isystem D:/android-ndk-r17c/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info   -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/android-ndk-r17c/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/android-ndk-r17c/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now    
    Linker flags (Debug):        -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/android-ndk-r17c/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/android-ndk-r17c/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now    
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          z dl m log
    3rdparty dependencies:       libcpufeatures ittnotify libprotobuf libjpeg-turbo libwebp libpng libtiff libjasper IlmImf quirc tegra_hal

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo shape stitching superres ts video videoio videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python2 python3 viz
    Applications:                tests perf_tests
    Documentation:               NO
    Non-free algorithms:         NO

  Android NDK:                   D:/android-ndk-r17c (ver 17.2.4988734)
    Android ABI:                 arm64-v8a
    NDK toolchain:               aarch64-linux-android-clang
    STL type:                    c++_static
    Native API level:            21
  Android SDK:                   not used, projects are not built

  GUI: 

  Media I/O: 
    ZLib:                        z (ver 1.2.3)
    JPEG:                        build-libjpeg-turbo (ver 2.0.2-62)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES

  Video I/O:

  Parallel framework:            pthreads

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Custom HAL:                  YES (carotene (ver 0.0.1))
    Protobuf:                    build (3.5.1)

  Python (for build):            D:/Anaconda3/envs/py35/python.exe

  Java:                          export all functions
    ant:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    D:/Program Files (x86)/opencv-3.4.9/sources/build_android64/install
-----------------------------------------------------------------

Configuring done

 

 然后点击Generate

执行mingw64.exe 进入D:\Program Files (x86)\opencv-3.4.9\sources\build_android64目录下编译命令:

mingw32-make

 

 

安装:

mingw32-make install

 

 安装完成后在install路径下文件夹结构:

 

D:.
├─apk
└─sdk
    ├─etc
    │  ├─haarcascades
    │  ├─lbpcascades
    │  └─licenses
    └─native
        ├─3rdparty
        │  └─libs
        │      └─arm64-v8a
        ├─jni
        │  ├─abi-arm64-v8a
        │  └─include
        │      ├─opencv
        │      └─opencv2
        │          ├─calib3d
        │          ├─core
        │          │  ├─cuda
        │          │  │  └─detail
        │          │  ├─detail
        │          │  ├─hal
        │          │  ├─opencl
        │          │  │  └─runtime
        │          │  │      └─autogenerated
        │          │  └─utils
        │          ├─dnn
        │          │  └─utils
        │          ├─features2d
        │          │  └─hal
        │          ├─flann
        │          ├─highgui
        │          ├─imgcodecs
        │          ├─imgproc
        │          │  ├─detail
        │          │  └─hal
        │          ├─ml
        │          ├─objdetect
        │          ├─photo
        │          ├─shape
        │          ├─stitching
        │          │  └─detail
        │          ├─superres
        │          ├─video
        │          ├─videoio
        │          └─videostab
        └─staticlibs
            └─arm64-v8a
View Code

 

 

 

参考博客:

https://blog.csdn.net/qq_19313495/article/details/89709405

https://www.pianshen.com/article/2093368804/

 

posted @ 2020-03-31 22:52  巨鹿王十二  阅读(793)  评论(0编辑  收藏  举报