Forums - OpenCV and FastCV static linking

3 posts / 0 new
Last post
OpenCV and FastCV static linking
razvan23
Join Date: 24 Mar 13
Posts: 4
Posted: Thu, 2015-11-05 14:43
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)
    
    OPENCV_CAMERA_MODULES:=on
    OPENCV_INSTALL_MODULES:=on
    
    include /Users/Razvan/Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk
    
    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)
 
 
I get weird undefined reference errors in the OpenCV native library, for example:
 
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:353: error: undefined reference to 'cv::Mat::create(int, int const*, int)'
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:278: error: undefined reference to 'cv::fastFree(void*)'
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:278: error: undefined reference to 'cv::fastFree(void*)'
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:278: error: undefined reference to 'cv::fastFree(void*)'
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:367: error: undefined reference to 'cv::Mat::deallocate()'
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:367: error: undefined reference to 'cv::Mat::deallocate()'
    /Users/Razvan/Android/OpenCV-2.4.11-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:367: error: undefined reference to 'cv::Mat::deallocate()'
 
 
The strange thing is that if I remove the FastCV stuff, OPenCV will compile and work perfectly. I do NOT want to use dynamic linking and the OpenCV manager. Does anyone have any suggestions for my issue?
 
Thanks!
  • Up0
  • Down0
krishanu6690
Join Date: 24 Nov 13
Posts: 10
Posted: Thu, 2015-11-05 21:42

Can you please remove -lfastcv from LOCAL_LDLIBS +=  -llog -ldl $(OPENGLES_LIB) -lfastcv  and try once?

In my opinion, we LOCAL_LDLIBS for system library dependencies. If we want to point to another library, it is better to use it only in LOCAL_STATIC_LIBRARIES and LOCAL_SHARED_LIBRARIES

  • Up0
  • Down0
razvan23
Join Date: 24 Mar 13
Posts: 4
Posted: Fri, 2015-11-06 09:04

The way it works is by modifying shared libs as follows:

LOCAL_SHARED_LIBRARIES += lopencv_java liblog libGLESv2

 

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.