在 Windows 上使用 MinGW 使用 SFM 模块为 Android 编译 OpenCV
Compiling OpenCV for Android with SFM module using MinGW on Windows
我正在尝试使用 contrib 模块为 Android 编译 OpenCV,主要是我对 sfm 感兴趣。我做了很多研究,最后我做了以下以支持 sfm:
已编译的 gflags
编译日志
编译谷神星
之后我使用这个cmake命令构建并生成(下面给出了部分输出):
> D:\ANDROID_OCV\opencv\build>"D:\Program Files\CMake\bin\cmake.exe" -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_PREFIX="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake" -DWITH_CUDA=OFF -DANDROID_NDK="D:\Android\Sdk\ndk\22.0.7026061" -DANDROID_SDK="D:\Android\Sdk" -DCMAKE_TOOLCHAIN_FILE="D:\Android\Sdk\ndk\22.0.7026061\build\cmake\android.toolchain.cmake" -DANDROID_NDK_HOST_X64=ON -DOPENCV_EXTRA_MODULES_PATH="D:\ANDROID_OCV\opencv\platforms\android_arm\opencv_contrib\modules" -DWITH_EIGEN=ON -DEigen3_DIR="D:\INSTALL\Development\lib\ceres-mingw\eigen\include\eigen3" -DEIGEN_INCLUDE_PATH="D:\INSTALL\Development\lib\ceres-mingw\eigen\include\eigen3" -Dgflags_DIR="D:\INSTALL\Development\lib\ceres-mingw\gflags\build" -DGFLAGS_INCLUDE_DIR="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\include" -DGFLAGS_INCLUDE_DIR_HINTS="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\include" -DGFLAGS_LIBRARY_DIR_HINTS="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\lib" -DGFLAGS_LIBRARY="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\lib\libgflags_static.a" -DGFLAGS_NAMESPACE=google -DGFLAGS_IN_GOOGLE_NAMESPACE=1 -DGLOG_DIR="D:\INSTALL\Development\lib\ceres-mingw\glog\build" -DGLOG_INCLUDE_DIR="D:\INSTALL\Development\lib\ceres-mingw\glog\build" -DGLOG_LIBRARY_DIR_HINTS="D:\INSTALL\Development\lib\ceres-mingw\glog\build\Release" -DGLOG_LIBRARY="D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a" -DGlog_LIBS="D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a" -DWITH_CERES=ON -DCERES_DIR="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake" -DCeres_DIR="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake" -DCeres_INCLUDE_DIR="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\include" -DCeres_LIBRARY="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a" -DCeres_LIB="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a" -DOPENCV_ENABLE_NONFREE=ON -DBUILD_EXAMPLES=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DINSTALL_ANDROID_EXAMPLES=OFF -DBUILD_TESTS=OFF -DINSTALL_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DINSTALL_PERF_TESTS=OFF -FBUILD_C_SAMPLES=OFF -DINSTALL_C_SAMPLES=OFF -DOPENCV_FORCE_3RDPARTY_BUILD=ON "D:\ANDROID_OCV\opencv"
-- ANDROID_PLATFORM not set. Defaulting to minimum supported version
16.
-- The CXX compiler identification is Clang 11.0.5
-- The C compiler identification is Clang 11.0.5
-- Check for working CXX compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: armv7-a
-- Found PythonInterp: D:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found suitable version "3.6.6", minimum required is "2.7")
CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:
PYTHON_EXECUTABLE=D:/Program Files (x86)/Microsoft Visual
Studio/Shared/Python36_64/python.exe
PYTHON_VERSION_STRING=3.6.6
Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
or environment variables
Call Stack (most recent call first):
cmake/OpenCVDetectPython.cmake:271 (find_python)
CMakeLists.txt:611 (include)
-- Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
-- Found PythonInterp: D:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found suitable version "3.6.6", minimum required is "3.2")
. . . . . .
. . . . . .
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE_SWITCH - Success
-- Android SDK Tools: ver. 26.1.1 (description: 'Android SDK Tools')
-- Android SDK Build Tools: ver. 30.0.3 (subdir 30.0.3 from 28.0.3;30.0.3)
-- Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK
-- Android SDK Build Tools: Gradle 3.0.0+ builds support is available
-- Android SDK Tools: Prepare Android projects for using Gradle 3.0.0+ build scripts
-- Android Gradle Plugin version: 3.2.1
-- Looking for dlerror in dl
-- Looking for dlerror in dl - found
-- ADE: Download: v0.1.1f.zip
-- Caffe: NO
-- Protobuf: NO
-- Glog: YES
-- freetype2: NO
-- harfbuzz: NO
-- Julia not found. Not compiling Julia Bindings.
-- Module opencv_ovis disabled because OGRE3D was not found
-- Checking SFM glog/gflags deps... TRUE
-- >> Ceres_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> CERES_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> Ceres_INCLUDE_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\include
-- >> Ceres_LIBRARY: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- >> Ceres_LIB: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- Allocator metrics storage type: 'int'
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/ANDROID_OCV/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out ocl4dnn source code
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL - Success
-- rgbd: CERES support is disabled. Ceres Solver is Required for Posegraph optimization
-- xfeatures2d/boostdesc: Download: boostdesc_bgm.i
-- xfeatures2d/boostdesc: Download: boostdesc_bgm_bi.i
-- xfeatures2d/boostdesc: Download: boostdesc_bgm_hd.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_064.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_128.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_256.i
-- xfeatures2d/boostdesc: Download: boostdesc_lbgm.i
-- xfeatures2d/vgg: Download: vgg_generated_48.i
-- xfeatures2d/vgg: Download: vgg_generated_64.i
-- xfeatures2d/vgg: Download: vgg_generated_80.i
-- xfeatures2d/vgg: Download: vgg_generated_120.i
-- data: Download: face_landmark_model.dat
-- >> Ceres_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> CERES_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> Ceres_INCLUDE_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\include
-- >> Ceres_LIBRARY: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- >> Ceres_LIB: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE - Failed
-- Performing Test HAVE_CXX_WNO_DEPRECATED_COPY
-- Performing Test HAVE_CXX_WNO_DEPRECATED_COPY - Success
-- Android OpenCV Manager is ignored
--
-- General configuration for OpenCV 4.5.1-dev =====================================
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): D:/ANDROID_OCV/opencv/platforms/android_arm/opencv_contrib/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2021-01-11T15:48:47Z
-- Host: Windows 10.0.18362 AMD64
-- Target: Android 1 armv7-a
-- CMake: 3.15.4
-- CMake generator: MinGW Makefiles
-- CMake build tool: D:/MinGW64/mingw64/bin/mingw32-make.exe
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: NEON
-- requested: DETECT
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 14
-- C++ Compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe (ver 11.0.5)
-- C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- C Compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -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,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: ade correspondence multiview numeric D:/INSTALL/Development/lib/ceres-mingw/glog/build/libglog.a D:/INSTALL/Development/lib/ceres-mingw/gflags/build/lib/libgflags_static.a simple_pipeline dl m log
-- 3rdparty dependencies: libcpufeatures ittnotify libprotobuf zlib libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf quirc tegra_hal
--
-- OpenCV modules:
-- To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf julia matlab ovis python2 python3 ts viz
-- Applications: -
-- Documentation: NO
-- Non-free algorithms: YES
--
-- Android NDK: D:/Android/Sdk/ndk/22.0.7026061 (ver 22.0.7026061)
-- Android ABI: armeabi-v7a
-- NDK toolchain: arm-linux-androideabi-clang
-- STL type: c++_static
-- Native API level: 16
-- Android SDK: D:\Android\Sdk (tools: 26.1.1 build tools: 30.0.3)
--
-- GUI:
--
-- Media I/O:
-- ZLib: build (ver 1.2.11)
-- JPEG: build-libjpeg-turbo (ver 2.0.6-62)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.0.10)
-- JPEG 2000: build (ver 2.3.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Eigen: YES (ver 3.3.7)
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
--
-- Python (for build): D:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe
--
-- Java: export all functions
-- ant: NO
-- Java wrappers: YES
-- Java tests: NO
--
-- Install to: D:/ANDROID_OCV/opencv/build/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: D:/ANDROID_OCV/opencv/build
我做的下一步是编译(下面给出了部分输出):
>"D:\MinGW64\mingw64\bin\mingw32-make.exe" -j10
[ 0%] Building C object 3rdparty/openjpeg/openjp2/CMakeFiles/libopenjp2.dir/thread.c.o
[ 0%] Building CXX object 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/absdiff.cpp.o
[ 0%] Building C object 3rdparty/ittnotify/CMakeFiles/ittnotify.dir/src/ittnotify/ittnotify_static.c.o
[ 0%] [ 0%] [ 0%] [ 0%] Building C object 3rdparty/cpufeatures/CMakeFiles/libcpufeatures.dir/cpu-features.c.oBuilding C object 3rdparty/zlib/CMakeFiles/zlib.dir/adler32.c.oBuilding C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/decode.c.o
Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jcapimin.c.o
[ 0%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.o
[ 0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/alloc.cpp.o
[ 0%] Built target opencv_videoio_plugins
[ 1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/compress.c.o
. . . . . . . . .
. . . . . . . . .
[ 99%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/src/input_array_utility.cpp.o
[ 99%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/src/optical_flow.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ie/giebackend/giewrapper.cpp.o
[ 99%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/src/super_resolution.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/onnx/gonnxbackend.cpp.o
[100%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/opencl_kernels_superres.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/render/grenderocv.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/render/ft_render.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/plaidml/gplaidmlcore.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/plaidml/gplaidmlbackend.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/gmetabackend.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/gcompoundbackend.cpp.o
[100%] Linking CXX static library ..\..\lib\armeabi-v7a\libopencv_superres.a
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/gcompoundkernel.cpp.o
[100%] Built target opencv_superres
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/s11n.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/serialization.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/streaming/gstreamingbackend.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ie/bindings_ie.cpp.o
[100%] Linking CXX static library ..\..\lib\armeabi-v7a\libopencv_gapi.a
[100%] Built target opencv_gapi
1 warning generated.
[100%] Linking CXX shared library ..\..\..\jni\armeabi-v7a\libopencv_java4.so
ld: error: D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a(logging.cc.obj): not an ELF file
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
mingw32-make[2]: *** [modules\java\jni\CMakeFiles\opencv_java.dir\build.make:269: jni/armeabi-v7a/libopencv_java4.so] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:6465: modules/java/jni/CMakeFiles/opencv_java.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
不幸的是,我无法在此处粘贴完整的输出,因为我超出了正文文本的限制,但没有任何(不是一条)错误消息。
一切都已成功编译,只有一个例外,当达到 100% 时出现错误,与 'libglog.a':
有关
[100%] Linking CXX shared library ..\..\..\jni\armeabi-v7a\libopencv_java4.so
ld: error: D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a(logging.cc.obj): not an ELF file
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
mingw32-make[2]: *** [modules\java\jni\CMakeFiles\opencv_java.dir\build.make:269: jni/armeabi-v7a/libopencv_java4.so] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:6465: modules/java/jni/CMakeFiles/opencv_java.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
请问是什么原因造成的,如何解决?
我编译成功 'libglog.a' 如此处解释(只有一个答案):
我刚刚用 android 完成了 opencv 的构建:
谷神星
#!/bin/bash
CMAKE_CONFIG_GENERATOR="MinGW Makefiles"
ANDROID_NDK=/F/Android_ndk/android-ndk-r18b
ANDROID_HOME=/F/Data_SDK_Android
echo "Installation de ceres "
myRepo=$(pwd)
echo $CMAKE_CONFIG_GENERATOR
RepoSource=gflags
cd Build/gflag_v7a
optCMAKE='-DCMAKE_TOOLCHAIN_FILE=/F/Android_ndk/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-25 -DINTTYPES_FORMAT:STRING=C99 -DNAMESPACE:STRING=google -DCMAKE_INSTALL_PREFIX=../../Install/gflags_v7a'
echo $CMAKE_CONFIG_GENERATOR
echo $optCMAKE
cmake -DBUILD_TESTING:BOOL=OFF -G"$CMAKE_CONFIG_GENERATOR" $optCMAKE ../../"$RepoSource"
cd ..
echo "************************* $Source_DIR -->release"
cmake --build gflag_v7a --config release
cmake --build gflag_v7a --target install --config release
cd ..
RepoSource=glog
cd Build/glog_v7a
optCMAKE='-DCMAKE_TOOLCHAIN_FILE=/F/Android_ndk/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-25 -DCMAKE_INSTALL_PREFIX=../../Install/glog_v7a'
cmake -DBUILD_TESTING:BOOL=OFF -G"$CMAKE_CONFIG_GENERATOR" $optCMAKE ../../"$RepoSource"
cd ..
echo "************************* $Source_DIR -->release"
cmake --build glog_v7a --config release
cmake --build glog_v7a --target install --config release
cd ..
RepoSource=ceres-solver
cd Build/ceres-solver_v7a
optCMAKE='-DCMAKE_TOOLCHAIN_FILE=/F/Android_ndk/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-25 -DEIGEN_INCLUDE_DIR=../../eigen -DCMAKE_INSTALL_PREFIX=../../Install/ceres-solver_v7a -DEigen3_DIR=/G/Lib/build/eigen \'
cmake -G"$CMAKE_CONFIG_GENERATOR" $optCMAKE -Dglog_DIR:PATH="$myRepo"/Install/glog_v7a/lib/cmake/glog -DBUILD_SHARED_LIBS=ON -DMINIGLOG=ON -Dgflags_DIR:PATH=/Install/gflags_v7a/lib/cmake/gflags ../../"$RepoSource"
cd ..
cmake --build ceres-solver_v7a --config release
cmake --build ceres-solver_v7a --target install --config release
cd ..
对于 opencv
myRepo=$(pwd)
RepoSource=opencv
CMAKE_CONFIG_GENERATOR="Ninja"
CMAKE_CONFIG_GENERATOR="MinGW Makefiles"
ANDROID_NDK=/F/Android_ndk/android-ndk-r18b
ANDROID_HOME=/F/Data_SDK_Android
installRepo=/g/lib/install
cd Build/opencvandroidv7a
CMAKE_OPTIONS='-DBUILD_opencv_world:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF -DBUILD_EXAMPLES:BOOL=ON -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_IPP=OFF -DWITH_MSMF=OFF -DCPU_DISPATCH='
cmake -DCMAKE_MAKE_PROGRAM=${ANDROID_NDK}/prebuilt/windows-x86_64/bin/make.exe \
-DWITH_EIGEN:BOOL=ON \
-DGLOG_LIBRARY=/G/Lib/install/glog_v7a/lib/libglog.a \
-DEigen3_DIR:PATH=/g/lib/install/Eigen3/share/eigen3/cmake \
-Dglog_DIR:PATH=/g/lib/Install/glog_v7a/lib/cmake/glog \
-Dgflags_DIR:PATH=/g/lib/Install/gflags_v7a/lib/cmake/gflags \
-DGLOG_INCLUDE_DIR=/g/lib/install/glog_v7a/include \
-DCeres_DIR=/g/lib/install/ceres-solver_v7a/lib/cmake/Ceres \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi \
-DJAVA_AWT_INCLUDE_PATH:PATH="C:/Program Files/Java/jdk1.8.0_152/include" \
-DJAVA_AWT_INCLUDE_PATH:PATH="C:/Program Files/Java/jdk1.8.0_152/include" \
-DJAVA_AWT_LIBRARY:FILEPATH="C:/Program Files/Java/jdk1.8.0_152/lib/jawt.lib" \
-DJAVA_INCLUDE_PATH:PATH="C:/Program Files/Java/jdk1.8.0_152/include" \
-DJAVA_INCLUDE_PATH2:PATH="C:/Program Files/Java/jdk1.8.0_152/include/win32" \
-DJAVA_JVM_LIBRARY:FILEPATH="C:/Program Files/Java/jdk1.8.0_152/lib/jvm.lib" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_SDK_ROOT:PATH=/F/Data_SDK_Android \
-DANDROID_NATIVE_API_LEVEL=25 \
-DANDROID_ARM_NEON=ON \
-DBUILD_ANDROID_PROJECTS:BOOL=ON \
-DANT_EXECUTABLE:FILEPATH=f:/apache-ant-1.10.5/bin/ant.bat \
-G"$CMAKE_CONFIG_GENERATOR" \
$CMAKE_OPTIONS -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DOPENCV_ENABLE_NONFREE:BOOL=OFF \
-DINSTALL_CREATE_DISTRIB=ON -DCMAKE_INSTALL_PREFIX=/g/lib/install/opencv ../../"$RepoSource"
cd ..
cmake --build opencvandroidv7a --config release
cmake --build opencvandroidv7a --target install --config release
cd ..
我正在尝试使用 contrib 模块为 Android 编译 OpenCV,主要是我对 sfm 感兴趣。我做了很多研究,最后我做了以下以支持 sfm:
已编译的 gflags 编译日志 编译谷神星
之后我使用这个cmake命令构建并生成(下面给出了部分输出):
> D:\ANDROID_OCV\opencv\build>"D:\Program Files\CMake\bin\cmake.exe" -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_PREFIX="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake" -DWITH_CUDA=OFF -DANDROID_NDK="D:\Android\Sdk\ndk\22.0.7026061" -DANDROID_SDK="D:\Android\Sdk" -DCMAKE_TOOLCHAIN_FILE="D:\Android\Sdk\ndk\22.0.7026061\build\cmake\android.toolchain.cmake" -DANDROID_NDK_HOST_X64=ON -DOPENCV_EXTRA_MODULES_PATH="D:\ANDROID_OCV\opencv\platforms\android_arm\opencv_contrib\modules" -DWITH_EIGEN=ON -DEigen3_DIR="D:\INSTALL\Development\lib\ceres-mingw\eigen\include\eigen3" -DEIGEN_INCLUDE_PATH="D:\INSTALL\Development\lib\ceres-mingw\eigen\include\eigen3" -Dgflags_DIR="D:\INSTALL\Development\lib\ceres-mingw\gflags\build" -DGFLAGS_INCLUDE_DIR="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\include" -DGFLAGS_INCLUDE_DIR_HINTS="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\include" -DGFLAGS_LIBRARY_DIR_HINTS="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\lib" -DGFLAGS_LIBRARY="D:\INSTALL\Development\lib\ceres-mingw\gflags\build\lib\libgflags_static.a" -DGFLAGS_NAMESPACE=google -DGFLAGS_IN_GOOGLE_NAMESPACE=1 -DGLOG_DIR="D:\INSTALL\Development\lib\ceres-mingw\glog\build" -DGLOG_INCLUDE_DIR="D:\INSTALL\Development\lib\ceres-mingw\glog\build" -DGLOG_LIBRARY_DIR_HINTS="D:\INSTALL\Development\lib\ceres-mingw\glog\build\Release" -DGLOG_LIBRARY="D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a" -DGlog_LIBS="D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a" -DWITH_CERES=ON -DCERES_DIR="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake" -DCeres_DIR="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake" -DCeres_INCLUDE_DIR="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\include" -DCeres_LIBRARY="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a" -DCeres_LIB="D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a" -DOPENCV_ENABLE_NONFREE=ON -DBUILD_EXAMPLES=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DINSTALL_ANDROID_EXAMPLES=OFF -DBUILD_TESTS=OFF -DINSTALL_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DINSTALL_PERF_TESTS=OFF -FBUILD_C_SAMPLES=OFF -DINSTALL_C_SAMPLES=OFF -DOPENCV_FORCE_3RDPARTY_BUILD=ON "D:\ANDROID_OCV\opencv"
-- ANDROID_PLATFORM not set. Defaulting to minimum supported version
16.
-- The CXX compiler identification is Clang 11.0.5
-- The C compiler identification is Clang 11.0.5
-- Check for working CXX compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: armv7-a
-- Found PythonInterp: D:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found suitable version "3.6.6", minimum required is "2.7")
CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:
PYTHON_EXECUTABLE=D:/Program Files (x86)/Microsoft Visual
Studio/Shared/Python36_64/python.exe
PYTHON_VERSION_STRING=3.6.6
Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
or environment variables
Call Stack (most recent call first):
cmake/OpenCVDetectPython.cmake:271 (find_python)
CMakeLists.txt:611 (include)
-- Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
-- Found PythonInterp: D:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found suitable version "3.6.6", minimum required is "3.2")
. . . . . .
. . . . . .
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE_SWITCH - Success
-- Android SDK Tools: ver. 26.1.1 (description: 'Android SDK Tools')
-- Android SDK Build Tools: ver. 30.0.3 (subdir 30.0.3 from 28.0.3;30.0.3)
-- Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK
-- Android SDK Build Tools: Gradle 3.0.0+ builds support is available
-- Android SDK Tools: Prepare Android projects for using Gradle 3.0.0+ build scripts
-- Android Gradle Plugin version: 3.2.1
-- Looking for dlerror in dl
-- Looking for dlerror in dl - found
-- ADE: Download: v0.1.1f.zip
-- Caffe: NO
-- Protobuf: NO
-- Glog: YES
-- freetype2: NO
-- harfbuzz: NO
-- Julia not found. Not compiling Julia Bindings.
-- Module opencv_ovis disabled because OGRE3D was not found
-- Checking SFM glog/gflags deps... TRUE
-- >> Ceres_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> CERES_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> Ceres_INCLUDE_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\include
-- >> Ceres_LIBRARY: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- >> Ceres_LIB: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- Allocator metrics storage type: 'int'
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/ANDROID_OCV/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out ocl4dnn source code
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL - Success
-- rgbd: CERES support is disabled. Ceres Solver is Required for Posegraph optimization
-- xfeatures2d/boostdesc: Download: boostdesc_bgm.i
-- xfeatures2d/boostdesc: Download: boostdesc_bgm_bi.i
-- xfeatures2d/boostdesc: Download: boostdesc_bgm_hd.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_064.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_128.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_256.i
-- xfeatures2d/boostdesc: Download: boostdesc_lbgm.i
-- xfeatures2d/vgg: Download: vgg_generated_48.i
-- xfeatures2d/vgg: Download: vgg_generated_64.i
-- xfeatures2d/vgg: Download: vgg_generated_80.i
-- xfeatures2d/vgg: Download: vgg_generated_120.i
-- data: Download: face_landmark_model.dat
-- >> Ceres_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> CERES_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\CMake
-- >> Ceres_INCLUDE_DIR: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\include
-- >> Ceres_LIBRARY: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- >> Ceres_LIB: D:\INSTALL\Development\lib\ceres-mingw\ceres-bin\install\lib\libceres.a
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE - Failed
-- Performing Test HAVE_CXX_WNO_DEPRECATED_COPY
-- Performing Test HAVE_CXX_WNO_DEPRECATED_COPY - Success
-- Android OpenCV Manager is ignored
--
-- General configuration for OpenCV 4.5.1-dev =====================================
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): D:/ANDROID_OCV/opencv/platforms/android_arm/opencv_contrib/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2021-01-11T15:48:47Z
-- Host: Windows 10.0.18362 AMD64
-- Target: Android 1 armv7-a
-- CMake: 3.15.4
-- CMake generator: MinGW Makefiles
-- CMake build tool: D:/MinGW64/mingw64/bin/mingw32-make.exe
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: NEON
-- requested: DETECT
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 14
-- C++ Compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe (ver 11.0.5)
-- C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- C Compiler: D:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -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 -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -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,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: ade correspondence multiview numeric D:/INSTALL/Development/lib/ceres-mingw/glog/build/libglog.a D:/INSTALL/Development/lib/ceres-mingw/gflags/build/lib/libgflags_static.a simple_pipeline dl m log
-- 3rdparty dependencies: libcpufeatures ittnotify libprotobuf zlib libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf quirc tegra_hal
--
-- OpenCV modules:
-- To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf julia matlab ovis python2 python3 ts viz
-- Applications: -
-- Documentation: NO
-- Non-free algorithms: YES
--
-- Android NDK: D:/Android/Sdk/ndk/22.0.7026061 (ver 22.0.7026061)
-- Android ABI: armeabi-v7a
-- NDK toolchain: arm-linux-androideabi-clang
-- STL type: c++_static
-- Native API level: 16
-- Android SDK: D:\Android\Sdk (tools: 26.1.1 build tools: 30.0.3)
--
-- GUI:
--
-- Media I/O:
-- ZLib: build (ver 1.2.11)
-- JPEG: build-libjpeg-turbo (ver 2.0.6-62)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.0.10)
-- JPEG 2000: build (ver 2.3.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Eigen: YES (ver 3.3.7)
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
--
-- Python (for build): D:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe
--
-- Java: export all functions
-- ant: NO
-- Java wrappers: YES
-- Java tests: NO
--
-- Install to: D:/ANDROID_OCV/opencv/build/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: D:/ANDROID_OCV/opencv/build
我做的下一步是编译(下面给出了部分输出):
>"D:\MinGW64\mingw64\bin\mingw32-make.exe" -j10
[ 0%] Building C object 3rdparty/openjpeg/openjp2/CMakeFiles/libopenjp2.dir/thread.c.o
[ 0%] Building CXX object 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/absdiff.cpp.o
[ 0%] Building C object 3rdparty/ittnotify/CMakeFiles/ittnotify.dir/src/ittnotify/ittnotify_static.c.o
[ 0%] [ 0%] [ 0%] [ 0%] Building C object 3rdparty/cpufeatures/CMakeFiles/libcpufeatures.dir/cpu-features.c.oBuilding C object 3rdparty/zlib/CMakeFiles/zlib.dir/adler32.c.oBuilding C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/decode.c.o
Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jcapimin.c.o
[ 0%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.o
[ 0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/alloc.cpp.o
[ 0%] Built target opencv_videoio_plugins
[ 1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/compress.c.o
. . . . . . . . .
. . . . . . . . .
[ 99%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/src/input_array_utility.cpp.o
[ 99%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/src/optical_flow.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ie/giebackend/giewrapper.cpp.o
[ 99%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/src/super_resolution.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/onnx/gonnxbackend.cpp.o
[100%] Building CXX object modules/superres/CMakeFiles/opencv_superres.dir/opencl_kernels_superres.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/render/grenderocv.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/render/ft_render.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/plaidml/gplaidmlcore.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/plaidml/gplaidmlbackend.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/gmetabackend.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/gcompoundbackend.cpp.o
[100%] Linking CXX static library ..\..\lib\armeabi-v7a\libopencv_superres.a
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/gcompoundkernel.cpp.o
[100%] Built target opencv_superres
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/s11n.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/serialization.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/streaming/gstreamingbackend.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ie/bindings_ie.cpp.o
[100%] Linking CXX static library ..\..\lib\armeabi-v7a\libopencv_gapi.a
[100%] Built target opencv_gapi
1 warning generated.
[100%] Linking CXX shared library ..\..\..\jni\armeabi-v7a\libopencv_java4.so
ld: error: D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a(logging.cc.obj): not an ELF file
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
mingw32-make[2]: *** [modules\java\jni\CMakeFiles\opencv_java.dir\build.make:269: jni/armeabi-v7a/libopencv_java4.so] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:6465: modules/java/jni/CMakeFiles/opencv_java.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
不幸的是,我无法在此处粘贴完整的输出,因为我超出了正文文本的限制,但没有任何(不是一条)错误消息。 一切都已成功编译,只有一个例外,当达到 100% 时出现错误,与 'libglog.a':
有关[100%] Linking CXX shared library ..\..\..\jni\armeabi-v7a\libopencv_java4.so
ld: error: D:\INSTALL\Development\lib\ceres-mingw\glog\build\libglog.a(logging.cc.obj): not an ELF file
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
mingw32-make[2]: *** [modules\java\jni\CMakeFiles\opencv_java.dir\build.make:269: jni/armeabi-v7a/libopencv_java4.so] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:6465: modules/java/jni/CMakeFiles/opencv_java.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
请问是什么原因造成的,如何解决?
我编译成功 'libglog.a' 如此处解释(只有一个答案):
我刚刚用 android 完成了 opencv 的构建:
谷神星
#!/bin/bash
CMAKE_CONFIG_GENERATOR="MinGW Makefiles"
ANDROID_NDK=/F/Android_ndk/android-ndk-r18b
ANDROID_HOME=/F/Data_SDK_Android
echo "Installation de ceres "
myRepo=$(pwd)
echo $CMAKE_CONFIG_GENERATOR
RepoSource=gflags
cd Build/gflag_v7a
optCMAKE='-DCMAKE_TOOLCHAIN_FILE=/F/Android_ndk/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-25 -DINTTYPES_FORMAT:STRING=C99 -DNAMESPACE:STRING=google -DCMAKE_INSTALL_PREFIX=../../Install/gflags_v7a'
echo $CMAKE_CONFIG_GENERATOR
echo $optCMAKE
cmake -DBUILD_TESTING:BOOL=OFF -G"$CMAKE_CONFIG_GENERATOR" $optCMAKE ../../"$RepoSource"
cd ..
echo "************************* $Source_DIR -->release"
cmake --build gflag_v7a --config release
cmake --build gflag_v7a --target install --config release
cd ..
RepoSource=glog
cd Build/glog_v7a
optCMAKE='-DCMAKE_TOOLCHAIN_FILE=/F/Android_ndk/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-25 -DCMAKE_INSTALL_PREFIX=../../Install/glog_v7a'
cmake -DBUILD_TESTING:BOOL=OFF -G"$CMAKE_CONFIG_GENERATOR" $optCMAKE ../../"$RepoSource"
cd ..
echo "************************* $Source_DIR -->release"
cmake --build glog_v7a --config release
cmake --build glog_v7a --target install --config release
cd ..
RepoSource=ceres-solver
cd Build/ceres-solver_v7a
optCMAKE='-DCMAKE_TOOLCHAIN_FILE=/F/Android_ndk/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-25 -DEIGEN_INCLUDE_DIR=../../eigen -DCMAKE_INSTALL_PREFIX=../../Install/ceres-solver_v7a -DEigen3_DIR=/G/Lib/build/eigen \'
cmake -G"$CMAKE_CONFIG_GENERATOR" $optCMAKE -Dglog_DIR:PATH="$myRepo"/Install/glog_v7a/lib/cmake/glog -DBUILD_SHARED_LIBS=ON -DMINIGLOG=ON -Dgflags_DIR:PATH=/Install/gflags_v7a/lib/cmake/gflags ../../"$RepoSource"
cd ..
cmake --build ceres-solver_v7a --config release
cmake --build ceres-solver_v7a --target install --config release
cd ..
对于 opencv
myRepo=$(pwd)
RepoSource=opencv
CMAKE_CONFIG_GENERATOR="Ninja"
CMAKE_CONFIG_GENERATOR="MinGW Makefiles"
ANDROID_NDK=/F/Android_ndk/android-ndk-r18b
ANDROID_HOME=/F/Data_SDK_Android
installRepo=/g/lib/install
cd Build/opencvandroidv7a
CMAKE_OPTIONS='-DBUILD_opencv_world:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF -DBUILD_EXAMPLES:BOOL=ON -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_IPP=OFF -DWITH_MSMF=OFF -DCPU_DISPATCH='
cmake -DCMAKE_MAKE_PROGRAM=${ANDROID_NDK}/prebuilt/windows-x86_64/bin/make.exe \
-DWITH_EIGEN:BOOL=ON \
-DGLOG_LIBRARY=/G/Lib/install/glog_v7a/lib/libglog.a \
-DEigen3_DIR:PATH=/g/lib/install/Eigen3/share/eigen3/cmake \
-Dglog_DIR:PATH=/g/lib/Install/glog_v7a/lib/cmake/glog \
-Dgflags_DIR:PATH=/g/lib/Install/gflags_v7a/lib/cmake/gflags \
-DGLOG_INCLUDE_DIR=/g/lib/install/glog_v7a/include \
-DCeres_DIR=/g/lib/install/ceres-solver_v7a/lib/cmake/Ceres \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi \
-DJAVA_AWT_INCLUDE_PATH:PATH="C:/Program Files/Java/jdk1.8.0_152/include" \
-DJAVA_AWT_INCLUDE_PATH:PATH="C:/Program Files/Java/jdk1.8.0_152/include" \
-DJAVA_AWT_LIBRARY:FILEPATH="C:/Program Files/Java/jdk1.8.0_152/lib/jawt.lib" \
-DJAVA_INCLUDE_PATH:PATH="C:/Program Files/Java/jdk1.8.0_152/include" \
-DJAVA_INCLUDE_PATH2:PATH="C:/Program Files/Java/jdk1.8.0_152/include/win32" \
-DJAVA_JVM_LIBRARY:FILEPATH="C:/Program Files/Java/jdk1.8.0_152/lib/jvm.lib" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_SDK_ROOT:PATH=/F/Data_SDK_Android \
-DANDROID_NATIVE_API_LEVEL=25 \
-DANDROID_ARM_NEON=ON \
-DBUILD_ANDROID_PROJECTS:BOOL=ON \
-DANT_EXECUTABLE:FILEPATH=f:/apache-ant-1.10.5/bin/ant.bat \
-G"$CMAKE_CONFIG_GENERATOR" \
$CMAKE_OPTIONS -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DOPENCV_ENABLE_NONFREE:BOOL=OFF \
-DINSTALL_CREATE_DISTRIB=ON -DCMAKE_INSTALL_PREFIX=/g/lib/install/opencv ../../"$RepoSource"
cd ..
cmake --build opencvandroidv7a --config release
cmake --build opencvandroidv7a --target install --config release
cd ..