How to rebuild OpenCv with c++_static?

有些话、适合烂在心里 提交于 2019-12-11 01:08:48

问题


I am new to opencv in android. I imported the opencv module 3.4.2 successfully. In application.mk

APP_STL:=gnustl_static

When I tried to build the application, I got NDK build error that 'gnustl_static' is no longer supported. I changed the above line in application.mk to

APP_STL:=c++_static as suggested by android studio.

The build was successful and I ran the project successfully. Now I tried to implement the face detection with opencv as like as opencv samples 'face-detection'. I got the error this time :

E:/MyOpenDetections/app/src/main/jni/com_sar_pahc_DetectionBasedTracker.cpp:37: error: undefined reference to 'cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__ndk1::vector<cv::Rect_<int>, std::__ndk1::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'

I searched about this and got some suggestions that I have to change the APP_STL to 'gnustl_static' from 'c++_static' but when I do this the NDK stops the build and shows that it is not supported now.

I got some hint from Alex Cohn that I have to rebuild the Opencv with c++_static OpenCV - undefined reference to 'cv::CascadeClassifier::detectMultiScale() after NDK update

But I have no idea of doing that. Please help


回答1:


You can try solution from opencv bugtracker (source):

cmake -GNinja -DINSTALL_ANDROID_EXAMPLES=ON -DANDROID_EXAMPLES_WITH_LIBS=ON -DBUILD_EXAMPLES=ON -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DWITH_IPP=ON -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang "-DANDROID_STL=c++_static" -DANDROID_ABI=x86 -DANDROID_SDK_TARGET=18 ../opencv

Followed by

make && make install



来源:https://stackoverflow.com/questions/52886556/how-to-rebuild-opencv-with-c-static

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