构建Android OpenCV和FastCV

时间:2015-11-05 22:41:21

标签: android c++ opencv

将OpenCV和FastCV构建为静态库时遇到问题。这是我的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)

我在OpenCV本机库中得到了奇怪的未定义引用错误,例如:

/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()'

奇怪的是,如果我删除FastCV的东西,OPenCV将编译并完美地工作。我不想使用动态链接和OpenCV管理器。有没有人对我的问题有任何建议?

谢谢!

1 个答案:

答案 0 :(得分:0)

通过更改Android.mk中的共享库来解决,如下所示:

LOCAL_SHARED_LIBRARIES += lopencv_java liblog libGLESv2