rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
136 stars 18 forks source link

Not able to compile for android after version 1.3.0 #293

Closed ferraridamiano closed 3 days ago

ferraridamiano commented 4 days ago

Describe the bug Compilation error for android. On arch linux I am unable to compile the stitching example of awesome opencv dart (I just changed opencv_dart to 1.3.2) for android. Prior to 1.3.0 I had no issue.

Here's the error:

Error log ```bash FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':opencv_dart:buildCMakeRelease[arm64-v8a]'. > com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/damiano/.pub-cache/hosted/pub.dev/opencv_dart-1.3.2/android/.cxx/Release/4c6wmg57/arm64-v8a' [1/1] Linking CXX shared library /home/damiano/Desktop/awesome-opencv_dart/examples/stitching/build/opencv_dart/intermediates/cxx/Release/4c6wmg57/obj/arm64-v8a/libdartcv.so FAILED: /home/damiano/Desktop/awesome-opencv_dart/examples/stitching/build/opencv_dart/intermediates/cxx/Release/4c6wmg57/obj/arm64-v8a/libdartcv.so : && /home/damiano/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --gcc-toolchain=/home/damiano/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/damiano/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -DNDEBUG -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libdartcv.so -o /home/damiano/Desktop/awesome-opencv_dart/examples/stitching/build/opencv_dart/intermediates/cxx/Release/4c6wmg57/obj/arm64-v8a/libdartcv.so _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/core/core.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/core/mat.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/core/exception.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/core/logging.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/core/svd.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/core/version.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/imgcodecs/imgcodecs.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/calib3d/calib3d.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/contrib/aruco.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/contrib/img_hash.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/contrib/quality.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/contrib/wechat_qrcode.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/contrib/ximgproc.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/contrib/xobjdetect.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/dnn/dnn.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/features2d/features2d.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/imgproc/imgproc.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/video/video.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/objdetect/objdetect.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/photo/photo.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/stitching/stitching.cpp.o _deps/libdartcv-build/dartcv/CMakeFiles/dartcv.dir/videoio/videoio.cpp.o _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_core.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_imgcodecs.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_calib3d.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_aruco.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_img_hash.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_quality.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_wechat_qrcode.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_ximgproc.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_xobjdetect.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_dnn.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_features2d.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_imgproc.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_video.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_objdetect.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_photo.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_stitching.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_videoio.a /usr/lib/libavdevice.so /usr/lib/libpostproc.so -lcamera2ndk -lmediandk -landroid _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_dnn.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/liblibprotobuf.a -llog _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/libquirc.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_xfeatures2d.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_ml.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_shape.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_calib3d.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_features2d.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_flann.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_imgcodecs.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/liblibjpeg-turbo.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/liblibwebp.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/liblibpng.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/liblibtiff.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/liblibopenjp2.a -pthread _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/libIlmImf.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_imgproc.a _deps/libopencv-src/sdk/native/staticlibs/arm64-v8a/libopencv_core.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/libzlib.a _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/libcpufeatures.a -ldl -lm -llog _deps/libopencv-src/sdk/native/3rdparty/libs/arm64-v8a/libtegra_hal.a _deps/libopencv-src/ffmpeg/lib/libavcodec.so _deps/libopencv-src/ffmpeg/lib/libavformat.so _deps/libopencv-src/ffmpeg/lib/libavfilter.so _deps/libopencv-src/ffmpeg/lib/libavutil.so _deps/libopencv-src/ffmpeg/lib/libswscale.so _deps/libopencv-src/ffmpeg/lib/libswresample.so -landroid -llog -lmediandk -landroid -llog -lcamera2ndk -landroid -latomic -lm && : ld: error: /usr/lib/libavdevice.so is incompatible with aarch64linux ld: error: /usr/lib/libpostproc.so is incompatible with aarch64linux clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. C++ build system [build] failed while executing: /home/damiano/Android/Sdk/cmake/3.18.1/bin/ninja \ -C \ /home/damiano/.pub-cache/hosted/pub.dev/opencv_dart-1.3.2/android/.cxx/Release/4c6wmg57/arm64-v8a \ dartcv from /home/damiano/.pub-cache/hosted/pub.dev/opencv_dart-1.3.2/android * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 10s Running Gradle task 'assembleRelease'... 10.8s Gradle task assembleRelease failed with exit code 1 ```
rainyl commented 3 days ago

@ferraridamiano

ld: error: /usr/lib/libavdevice.so is incompatible with aarch64linux ld: error: /usr/lib/libpostproc.so is incompatible with aarch64linux

It seems that you have installed ffmpeg system-wide ffmpeg, if you do not need videoio module, try to use opencv_core.

We need to fix the logic of ffmpeg-confi.cmake, specifically, remove system paths from search paths, if you need videoio module, please use the old versions and wait for the fix, I am kind of busy recently.

You can also try to fix it by yourself if you are familiar with cmake, take a look at

ferraridamiano commented 3 days ago

I decided to use opencv_core, so it's fixed for me. Thank you!