Ask Your Question
0

Build OpenCV + FastCV static linking

asked 2015-11-05 10:22:29 -0600

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!

edit retag flag offensive close merge delete

Comments

I also tried this:

OPENCV_LIB_TYPE:=STATIC
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on

include /Users/Razvan/Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk

But no luck.. because I get undefined reference errors in the c++ files of the opencv library. ex:

/Users/Razvan/Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:1804: error: undefined reference to 'cv::MatConstIterator::seek(int, bool)'
/Users/Razvan/Android/workspace/DriveAssist2Andra/DriveAssist_original/jni/GridTracking.cpp:1522: error: undefined reference to 'cv::operator*(cv::Mat const&, cv::Mat const&)'
/Users/Razvan/Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:1804: error: undefined reference to 'cv::MatConstIterator::see
razvan gravatar imagerazvan ( 2015-11-05 10:23:16 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-08 08:13:52 -0600

Solved by changing the shared libs in Android.mk as follows:

LOCAL_SHARED_LIBRARIES += lopencv_java liblog libGLESv2
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-05 10:22:29 -0600

Seen: 927 times

Last updated: Nov 08 '15