问题
I updated Android Studio to use the ndk18 and changed:
APP_STL := c++_static
This lead to a bunch of linker errors in OpenCv:
../thirdparty/opencv-android-sdk/sdk/native/jni/../libs/arm64-v8a/libopencv_objdetect.a(detection_based_tracker.cpp.o): In function `cv::DetectionBasedTracker::updateTrackedObjects(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > > const&)':
detection_based_tracker.cpp:(.text._ZN2cv21DetectionBasedTracker20updateTrackedObjectsERKSt6vectorINS_5Rect_IiEESaIS3_EE+0xad8): undefined reference to `std::__throw_length_error(char const*)'
../thirdparty/opencv-android-sdk/sdk/native/jni/../libs/arm64-v8a/libopencv_objdetect.a(detection_based_tracker.cpp.o): In function `_GLOBAL__sub_I_detection_based_tracker.cpp':
detection_based_tracker.cpp:(.text.startup._GLOBAL__sub_I_detection_based_tracker.cpp+0x18): undefined reference to `std::ios_base::Init::Init()'
detection_based_tracker.cpp:(.text.startup._GLOBAL__sub_I_detection_based_tracker.cpp+0x1c): undefined reference to `std::ios_base::Init::~Init()'
detection_based_tracker.cpp:(.text.startup._GLOBAL__sub_I_detection_based_tracker.cpp+0x34): undefined reference to `std::ios_base::Init::~Init()'
How to fix this?
I am using OpenCv android sdk 3.1.
回答1:
You need to rebuild opencv against libc++.
回答2:
you need to rebuild opencv based on NDK 18, i had done it with opencv 2.4
https://github.com/2666fff/opencv-for-android
来源:https://stackoverflow.com/questions/52436506/undefined-references-error-opencv-android-with-ndk-18-c-static