Build OpenCV + FastCV static linking
Hi, I am having issues when building OpenCV and FastCV as static libs. Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include /Users/Razvan/Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
USE_OPENGL_ES_1_1 := false
ifeq ($(USE_OPENGL_ES_1_1), true)
OPENGLES_LIB := -lGLESv1_CM
OPENGLES_DEF := -DUSE_OPENGL_ES_1_1
else
OPENGLES_LIB := -lGLESv2
OPENGLES_DEF := -DUSE_OPENGL_ES_2_0
endif
LOCAL_MODULE := drive_assist
LOCAL_SRC_FILES += jni_part.cpp GridTracking.cpp CameraRendererRGB565GL2.cpp FastCVSampleRenderer.cpp CameraUtil.cpp
LOCAL_LDLIBS += -llog -ldl $(OPENGLES_LIB) -lfastcv
LOCAL_CFLAGS += -Wno-write-strings $(OPENGLES_DEF) -ffast-math -O3 -fopenmp -funroll-loops
LOCAL_LDFLAGS +=-O3 -fopenmp
LOCAL_CPPFLAGS := -O3 -flto -ffunction-sections -fdata-sections
LOCAL_CPPFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
LOCAL_CPPFLAGS += -fomit-frame-pointer -funroll-loops -ffast-math
LOCAL_CPPFLAGS += -mfloat-abi=softfp -DFPM_ARM -DNDEBUG
LOCAL_STATIC_LIBRARIES += libfastcv
LOCAL_SHARED_LIBRARIES := liblog libGLESv2
include $(BUILD_SHARED_LIBRARY)
When I open the app I get this error:
11-05 15:23:12.500: D/OpenCV/StaticHelper(3391): Trying to load library opencv_java
11-05 15:23:12.500: D/OpenCV/StaticHelper(3391): Cannot load library "opencv_java"
11-05 15:23:12.500: W/System.err(3391): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/net.mobileway.driveassist2-2.apk"],nativeLibraryDirectories=[/data/app-lib/net.mobileway.driveassist2-2, /vendor/lib, /system/lib]]]: findLibrary returned null
If I remove the FastCV code, the OpenCV part works.. how can I make them both work? Thanks!
I also tried this:
But no luck.. because I get undefined reference errors in the c++ files of the opencv library. ex: