Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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)

Any workaround ?

Thanks in advance.

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

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.