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

asked 2018-11-29 10:12:27 -0600

Simontraww gravatar image

updated 2018-12-05 10:11:28 -0600

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 ...
(more)
edit retag flag offensive close merge delete

Comments

(no android user here ! but):

note, that all those errors are related to std::__ndk1::vector . you say, you build the libs with gnustl. can it be there's a mismatch between the stl used in the libs, and your current project ?

berak gravatar imageberak ( 2018-11-29 10:20:36 -0600 )edit

It's not a post for android user only, it's not a problem if you are not android dev. thanks for reply !!

hmm right, I think that's not a problem, but I'm not sure, because my whole project uses "c++_shared" with two exceptions:

  • G2o
  • Opencv.

G2o linked well, and provide not any errors. And I can't compile Opencv with other STL..

Regards.

Simontraww gravatar imageSimontraww ( 2018-11-29 10:43:11 -0600 )edit

I had also same 'undefined reference' error in the functions of the features2D module (version opencv 3.1.0). I managed to build opencv 3.1.0 with android-ndk-15c with custom settings by enabling BUILD_FAT_JAVA_LIBS flag. Hope it helps.

yildirimya gravatar imageyildirimya ( 2019-04-04 08:50:25 -0600 )edit