Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv (3.4.4) with NEON provide a few undefined symbols (ANDROID)

System information (version)

OpenCV => 3.4.4

Platform => ARM (armeabiv7-a)

Android API Level => 24

Compiler => Clang 5.0

Android STL => gnustl_shared

NDK VERSION => NDK 15c

TOOLCHAIN USED => Opencv 3.4.4 toolchain android.

Goal of my request

Opti => NEON for Opencv (armeabiv7-a with NEON)

Introduction


My project, will use many things with Opencv, in Window we can't see a latency, however in Android we can see them.

After reading a lot of articles/forums/channels about Opencv with Android, I've seen that Opencv needed NEON on Android, ARM to do something well and without latency and run with optimizations

Configure / Make Shared Lib


So, to date, I have downloaded sources of opencv 3.4.4 from the official website, I have run it into my CMAKE-GUI, I've made a lot of correction to make a build successfully, but I would note that I haven't disable the essential modules from opencv like (core or any others).

(If it's necessary I can host my output of cmake here.)

Then after configure and make it, I have my shared library which will be linked into my Android studio project with cmakelists and other things..

After sync correct, I have made my project.

Errors occurred with Android Studio compile the project


So, I have encountered a few undefined symbols with opencv only.

We can see them :

   error: undefined reference to 'cv::read(cv::FileNode const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&)'
  error: undefined reference to 'cv::write(cv::FileStorage&, cv::String const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > const&)'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::read(cv::FileNode const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::drawKeypoints(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > const&, cv::_InputOutputArray const&, cv::Scalar_<double> const&, int)'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

I don't know what are she's doing, but I want these optimizations and I will be very grateful if you have some things to tell me.

Best Regards !!

Opencv (3.4.4) with NEON provide a few undefined symbols (ANDROID)

System information (version)

OpenCV => 3.4.4

Platform => ARM (armeabiv7-a)

Android API Level => 24

Compiler => Clang 5.0

Android STL => gnustl_shared

NDK VERSION => NDK 15c

TOOLCHAIN USED => Opencv 3.4.4 toolchain android.

Goal of my request

Opti => NEON for Opencv (armeabiv7-a with NEON)

Introduction


My project, will use many things with Opencv, in Window we can't see a latency, however in Android we can see them.

After reading a lot of articles/forums/channels about Opencv with Android, I've seen that Opencv needed NEON on Android, ARM to do something well and without latency and run with optimizations

Configure / Make Shared Lib


So, to date, I have downloaded sources of opencv 3.4.4 from the official website, I have run it into my CMAKE-GUI, I've made a lot of correction to make a build successfully, but I would note that I haven't disable the essential modules from opencv like (core or any others).

(If it's necessary I can host my output of cmake here.)

Then after configure and make it, I have my shared library which will be linked into my Android studio project with cmakelists and other things..

After sync correct, I have made my project.

Errors occurred with Android Studio compile the project


So, I have encountered a few undefined symbols with opencv only.

We can see them :

   error: undefined reference to 'cv::read(cv::FileNode const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&)'
  error: undefined reference to 'cv::write(cv::FileStorage&, cv::String const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > const&)'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::read(cv::FileNode const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, cv::_InputArray const&, std::__ndk1::vector<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> >, std::__ndk1::allocator<std::__ndk1::vector<cv::DMatch, std::__ndk1::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool) const'
  error: undefined reference to 'cv::drawKeypoints(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > const&, cv::_InputOutputArray const&, cv::Scalar_<double> const&, int)'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

I don't know what are she's doing, but I want these optimizations and I will be very grateful if you have some things to tell me.

Best Regards !!

EDIT :

I've test another config :

cmake -G "Unix Makefiles" 
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON 
-DTBB=ON 
-DWITH_NEON=ON 
-DWITH_EIGEN=ON 
-DWITH_OPENCL=ON 
-DBUILD_opencv_gpu=OFF 
-DCMAKE_TOOLCHAIN_FILE=/home/Documents/opencv-3.4.4/platforms/android/android.toolchain.cmake  
-DCMAKE_MAKE_PROGRAM=/home/Android/Sdk/ndk-bundle/prebuilt/linux-x86_64/bin/make 
-DANDROID_ABI="armeabi-v7a with NEON" 
-DOPENCV_EXTRA_MODULES_PATH=/home/Documents/opencv_contrib-3.4.4/modules/ 
-DBUILD_opencv_features2d=ON 
-DBUILD_opencv_ximgproc=ON 
-DBUILD_opencv_java=OFF 
-DCMAKE_BUILD_TYPE=RELEASE 
-DCXXFLAGS="-Wall -fpu=neon -O3" 
-DBUILD_JAVA=OFF 
-DBUILD_ANDROID_EXAMPLES=OFF 
-DEIGEN_INCLUDE_PATH=/home/deps/Eigen_3.3.4/include/eigen3/ 
-DANDROID_NATIVE_API_LEVEL=24 
-DCMAKE_ANDROID_API_MIN=24 
-DANDROID_NDK=/home/Android/Sdk/ndk-bundle/ 
-DBUILD_SHARED_LIBS=ON 
-DBUILD_DOCS=OFF 
-DANDROID_STL=gnustl_static

..


CMake Warning at cmake/OpenCVUtils.cmake:611 (message):
  Unexpected option: WITH_EIGEN (=ON)

  Condition: IF ((;NOT;WINRT;AND;NOT;CMAKE_CROSSCOMPILING;))
Call Stack (most recent call first):
  CMakeLists.txt:233 (OCV_OPTION)


-- Looking for ccache - not found
-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT
-- libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-3.4.4-libjpeg-turbo
-- Caffe:   NO
-- Protobuf:   NO
-- Glog:   NO
-- freetype2:   NO
-- harfbuzz:    NO
-- Module opencv_ovis disabled because OGRE3D was not found
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
-- Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
-- Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
-- Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
-- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.ssse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_1.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.fp16.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/filter.avx2.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
-- Excluding from source files list: modules/imgproc/src/undistort.avx2.cpp
-- 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
-- Excluding from source files list: modules/objdetect/src/haar.avx.cpp
-- 
-- General configuration for OpenCV 3.4.4 =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            /home/Documents/opencv_contrib-3.4.4/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2018-11-28T08:29:40Z
--     Host:                        Linux 4.15.0-39-generic x86_64
--     Target:                      Android 1 armv7-a
--     CMake:                       3.11.4
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /home/Android/Sdk/ndk-bundle/prebuilt/linux-x86_64/bin/make
--     Configuration:               RELEASE
-- 
--   CPU/HW features:
--     Baseline:                    NEON
--       requested:                 DETECT
--       required:                  NEON
--       disabled:                  VFPV3
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /home/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++  (ver 4.9.0)
--     C++ flags (Release):         -fexceptions -frtti -Wno-psabi --sysroot=/home/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack  -DANDROID -D__ANDROID_API__=24   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fexceptions -frtti -Wno-psabi --sysroot=/home/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack  -DANDROID -D__ANDROID_API__=24   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG  -DDEBUG -D_DEBUG
--     C Compiler:                  /home/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
--     C flags (Release):           -fexceptions -Wno-psabi --sysroot=/home/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack  -DANDROID -D__ANDROID_API__=24   -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfp16-format=ieee -fvisibility=hidden -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fexceptions -Wno-psabi --sysroot=/home/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack  -DANDROID -D__ANDROID_API__=24   -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfp16-format=ieee -fvisibility=hidden -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG  -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-allow-shlib-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now    
--     Linker flags (Debug):        -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-allow-shlib-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now    
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          dl m log
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts 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 java js matlab ovis python2 python3 sfm viz
--     Applications:                tests perf_tests
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   Android NDK:                   location: /home/Android/Sdk/ndk-bundle
--     Android ABI:                 armeabi-v7a with NEON
--     NDK toolchain:               arm-linux-androideabi-4.9
--     STL type:                    gnustl_static
--     Native API level:            24
--   Android SDK:                   (tools:  build tools: )
-- 
--   GUI: 
-- 
--   Media I/O: 
--     ZLib:                        z (ver 1.2.3)
--     JPEG:                        build-libjpeg-turbo (ver 1.5.3-62)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.35)
--     TIFF:                        build (ver 42 - 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
-- 
--   Video I/O:
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (built-in)
-- 
--   Other third-party libraries:
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/Documents/opencv-3.4.4/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Install to:                    /home/Documents/opencv-3.4.4/build_01/install
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/Documents/opencv-3.4.4/build_01

But nothing happened.. someone found something ?