I am upgrading an Android JNI project from OpenCV 3.4.3 to 4.1.1.
When building an issue came out :
error: undefined reference to 'cv::dnn::dnn4_v20190621::Net::setInput(cv::_InputArray const&, std::string const&, double, cv::Scalar_<double> const&)'
Indeed when I look inside libopencv_java4.so, the name of the function is
void cv::dnn::dnn4_v20190621::Net::setInput(cv::InputArray, const cv::String &, double, const cv::Scalar &)
So the .so don't have the extras '_' characters : _InputArray
vs InputArray
and Scalar_
vs Scalar
Any idea where the pb comes from ?
Others OpenCV modules seems okay but not the DNN module.
I am using CMake 3.6.0-rc2 on a Mac.
My CMakeLists.txt contains the following to link by target with the SHARED OpenCV Java library:
cmake_minimum_required(VERSION 3.6)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_java4.so
Executable : /Users/renaud/Library/Android/sdk/cmake/3.6.4111459/bin/cmake
arguments :
-H/Users/renaud/Documents/DEV/android-imaging/src/main/jni
-B/Users/renaud/Documents/DEV/android-imaging/.externalNativeBuild/cmake/debug/armeabi-v7a
-DANDROID_ABI=armeabi-v7a
-DANDROID_PLATFORM=android-22
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/renaud/Documents/DEV/android-imaging/build/intermediates/cmake/debug/obj/armeabi-v7a
-DCMAKE_BUILD_TYPE=Debug
-DANDROID_NDK=/Users/renaud/Library/Android/sdk/ndk-bundle
-DCMAKE_CXX_FLAGS=-frtti -fexceptions -std=c++11
-DCMAKE_TOOLCHAIN_FILE=/Users/renaud/Library/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake
-DCMAKE_MAKE_PROGRAM=/Users/renaud/Library/Android/sdk/cmake/3.6.4111459/bin/ninja
-GAndroid Gradle - Ninja
-DANDROID_STL=c++_shared
-DANDROID_STL=gnustl_shared
-DANDROID_ARM_NEON=TRUE
jvmArgs :
EDIT1 :
I rebuilt the Java SDK Manually from source to ensure 'include' directory is sync with 'libopencv_java4.so'. Same issue.
These are the symbols found in the .so :
nm -D -C jniLibs/armeabi-v7a/libopencv_java4.so | grep "setInput"
00109bf4 T Java_org_opencv_dnn_Model_setInputCrop_10
00109d78 T Java_org_opencv_dnn_Model_setInputMean_10
0010a5f8 T Java_org_opencv_dnn_Model_setInputParams_10
0010a6d8 T Java_org_opencv_dnn_Model_setInputParams_11
0010a7b4 T Java_org_opencv_dnn_Model_setInputParams_12
0010a888 T Java_org_opencv_dnn_Model_setInputParams_13
0010a948 T Java_org_opencv_dnn_Model_setInputParams_14
0010a9f8 T Java_org_opencv_dnn_Model_setInputParams_15
00109f14 T Java_org_opencv_dnn_Model_setInputScale_10
0010a094 T Java_org_opencv_dnn_Model_setInputSize_10
0010a228 T Java_org_opencv_dnn_Model_setInputSize_11
0010a3a8 T Java_org_opencv_dnn_Model_setInputSwapRB_10
0010d020 T Java_org_opencv_dnn_Net_setInput_10
0010d1ac T Java_org_opencv_dnn_Net_setInput_11
0010d320 T Java_org_opencv_dnn_Net_setInput_12
0010d498 T Java_org_opencv_dnn_Net_setInput_13
0010d57c T Java_org_opencv_dnn_Net_setInputsNames_10
0054c628 T cv::dnn::dnn4_v20190902::Net::setInputsNames(std::__ndk1::vector<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::allocator<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > > > const&)
0054c69c T cv::dnn::dnn4_v20190902::Net::setInput(cv::_InputArray const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, double, cv::Scalar_<double> const&)
005a2830 T cv::dnn::dnn4_v20190902::Model::setInputCrop(bool)
005a2804 T cv::dnn::dnn4_v20190902::Model::setInputMean(cv::Scalar_<double> const&)
005a27f0 T cv::dnn::dnn4_v20190902::Model::setInputSize(cv::Size_<int> const&)
005a27fc T cv::dnn::dnn4_v20190902::Model::setInputSize(int, int)
005a2828 T cv::dnn::dnn4_v20190902::Model::setInputScale(double)
005a2840 T cv::dnn::dnn4_v20190902::Model::setInputParams(double, cv::Size_<int> const&, cv::Scalar_<double> const&, bool, bool)
005a2838 T cv::dnn::dnn4_v20190902::Model::setInputSwapRB(bool)