Using Android NDK with OpenCV 3.4.1

asked 2018-07-10 11:10:58 -0500

omatrot gravatar image

I'm unable to make my native C++ code to link with OpenCV, both dynamically or statically. I have basically downloaded the Android SDK and extracted it in some place, then included the relevant path in the cmakelists.txt file.

Dynamically I have the following error :

bridge_impl.cpp:132: error: undefined reference to 'cv::imencode(cv::String const&, cv::_InputArray const&, std::__ndk1::vector<unsigned char,="" std::__ndk1::allocator<unsigned="" char=""> >&, std::__ndk1::vector<int, std::__ndk1::allocator<int=""> > const&)' bridge_impl.cpp:211: error: undefined reference to 'cv::imencode(cv::String const&, cv::_InputArray const&, std::__ndk1::vector<unsigned char,="" std::__ndk1::allocator<unsigned="" char=""> >&, std::__ndk1::vector<int, std::__ndk1::allocator<int=""> > const&)' clang++: error: linker command failed with exit code 1

My cmakelists.txt content is :

add_library(opencv_java3 SHARED IMPORTED)

set_target_properties(opencv_java3 PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/src/opencv/libs/${ANDROID_ABI}/libopencv_java3.so)

target_link_libraries(native-lib opencv_java3)

for what it's worth, the same code, which is cross platform, compiles and link fine on iOS.

Thanks for your help.

edit retag flag offensive close merge delete