Ask Your Question
0

workaround to link against libopencv_java3.so using cmake, ndk r16b ,clang and stl libc++_shared or libc++_static

asked 2018-01-28 12:53:37 -0500

walex gravatar image

updated 2018-01-28 13:03:15 -0500

Hello I'm trying to build a shared library (.so) for android , basically is a simple region detection module.

But if I link my library with stl = c++_shared I have the next error:

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>)' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

If I use stl = gnustl_shared everything works ok, but is not an option to me as the module will be part of a much bigger system which links against c++_shared ( due to a more complete implementation of c++ 11 standard ) also using gcc is also not an option because it is deprecated for ndk

Relevant piece of CMakeLists.txt is :

add_library(test_android SHARED ${TEST_ANDROID_SOURCES}) target_link_libraries(test_android ${OpenCV_LIBS}/armeabi-v7a/libopencv_java3.so)

I tried with opencv 3.3 and 3.4 and result is the same

Any workaround ?

Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-29 05:28:09 -0500

wout gravatar image

The standard OpenCV for Android is compiled against gnustl_static. To be able to link it against your own library you need to compile OpenCV yourself and change the STL type to c++_static

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-01-28 12:53:37 -0500

Seen: 400 times

Last updated: Jan 28 '18