opencv4.4.0 dnn module cannot compile

System information (version)
  • OpenCV 4.4.0
  • Operating System / Platform => arm64-v8a
  • Compiler => ndkr18b
  • Build on ubuntu18.04
Detailed description

Want to build opencv4.4.0 with tengine support, following is my cmake comand

cmake .. \
-DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=23 \
-DANDROID_ARM_NEON=ON -DANDROID_TOOLCHAIN=clang \
-DCMAKE_TOOLCHAIN_FILE=/home/yyyy/Android/Sdk/ndk/android-ndk-r18b-linux-x86_64/android-ndk-r18b/build/cmake/android.toolchain.cmake \
-DANDROID_NDK=/home/yyyy/Android/Sdk/ndk-bundle \
-DANDROID_SDK=/home/yyyy/Android/Sdk \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_opencv_world=OFF \
-DBUILD_opencv_gapi=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/home/yyyy/Qt/3rdLibs/opencv/build_android/install/armv7 \
-DBUILD_ANDROID_PROJECTS=OFF -DWITH_OPENCL=ON -DWITH_TBB=ON -DENABLE_NEON=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_TENGINE=ON

than run make, every modules work except of dnn, with error messages

../../3rdparty/lib/arm64-v8a/liblibprotobuf.a(common.cc.o): In function `google::protobuf::internal::DefaultLogHandler(google::protobuf::LogLevel, char const*, int, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)':
/home/yyyy/Qt/3rdLibs/opencv/3rdparty/protobuf/src/google/protobuf/stubs/common.cc:142: undefined reference to `__android_log_write'
/home/yyyy/Qt/3rdLibs/opencv/3rdparty/protobuf/src/google/protobuf/stubs/common.cc:150: undefined reference to `__android_log_write'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:2780: recipe for target 'lib/arm64-v8a/libopencv_dnn.so' failed
make[2]: *** [lib/arm64-v8a/libopencv_dnn.so] Error 1
CMakeFiles/Makefile2:1950: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/all' failed
make[1]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

ps : can build with armeabi-v7a

1 possible answer(s) on “opencv4.4.0 dnn module cannot compile

  1. I tried Android build from master with NDK 18b and everything is ok. My CMake options:

    cmake ../opencv-master -DBUILD_ANDROID_PROJECTS=OFF -DWITH_OPENCL=ON -DWITH_TBB=ON -DENABLE_NEON=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_TENGINE=ON -DBUILD_opencv_gapi=OFF -DBUILD_opencv_world=OFF -DBUILD_SHARED_LIBS=ON -DANDROID_ARM_NEON=ON -DANDROID_TOOLCHAIN=clang -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=23 -DCMAKE_TOOLCHAIN_FILE=/home/alexander/Android/android-ndk-r18b/build/cmake/android.toolchain.cmake -DANDROID_NDK=/home/alexander/Android/android-ndk-r18b/ -DANDROID_SDK=/home/alexander/Android/Sdk/