I'm trying to write a unity plugin for android (eventually also on IOS) that uses opencv.
I managed to get a normal helloworld.cpp compiled to a shared library using Android NDK Toolchain to arm7 architecture, I also do the same for x86, and included the resulting *.so to Plugin/Android/libs/x86 & Plugin/Android/libs/armeabi-v7a, and it worked fine (I returned a simple integer and looked at the logs on logcat).
The Problem is as soon as I try to compile my c++ code and link the static libraries of Opencv4Android (the compilation returns a relatively fat shared library without any problems), But I get dllExceptionNotFound once I run the apk generated by unity
here is the script that I use to compile a cpp code to all android architectures
#!/bin/bash
ANDROID_NDK_HOME=$(dirname "$(locate ndk-build | head -1)")
APP_ABI=android-9
target="ARMV7"
arch="arch-arm"
CCFolder="arm-linux-androideabi-4.9"
CC="arm-linux-androideabi-g++"
SYSROOT=${ANDROID_NDK_HOME}/platforms/${APP_ABI}/${arch}
command="${ANDROID_NDK_HOME}/toolchains/${CCFolder}/prebuilt/linux-x86_64/bin/${CC} --sysroot=$SYSROOT"
CPP_SRC="cpp/opencvTest.cpp"
ANDROID_LIB="libmylib.so"
OPENCV_INCLUDE="-I./opencv/include"
OPENCV_STATIC="-L./opencv/libs/armv7a \
-lopencv_calib3d \
-lopencv_highgui \
-lopencv_video \
-lopencv_objdetect \
-lopencv_imgproc \
-lopencv_imgcodecs \
-lopencv_core -ldl"
SYSROOT=${ANDROID_NDK_HOME}/platforms/${APP_ABI}/${arch}
command="${ANDROID_NDK_HOME}/toolchains/${CCFolder}/prebuilt/linux-x86_64/bin/${CC} --sysroot=$SYSROOT"
exec $($command $CPP_SRC -shared $OPENCV_INCLUDE -I$ANDROID_NDK_HOME/sources/cxx-stl/stlport/stlport -L$ANDROID_NDK_HOME/sources/cxx-stl/stlport/libs/${STL_PORT} -lstlport_static -fPIC -o ./libs/Android/libs/armv7a/$ANDROID_LIB -Wl,--whole-archive $OPENCV_STATIC -Wl,--no-whole-archive)
also, from my understanding of static linking, I don't need to copy .a, as the compilation step does that, is that's correct? I'm new with all of this, so any help is appreciated.