Undefined References Error OpenCv Android with ndk 18 (c++_static)

為{幸葍}努か 提交于 2021-01-27 17:30:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!