Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I support c++11 in Opencv 3 Android NDKdk

Hi, all

I am doing the next changes to support c++11 with opencv 3 in android NDK:

I change from APP_STL := gnustl_static to APP_STL := c++_static

APP_STL := c++_static
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions
APP_ABI :=  armeabi armeabi-v7a mips x86 arm64-v8a x86_64 mips64
APP_PLATFORM := android-14
# use this to select gcc instead of clang

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)


include ../../../OpenCV-android-sdk/sdk/native/jni/

LOCAL_MODULE:= detection_based_tracker

LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp \
                              library/jniUtils.cpp \
                             ${ LOCAL_PATH_LIB_DIR}/logic.cpp \
                             ${ LOCAL_PATH_LIB_DIR}/logic2.cpp \
 LOCAL_LDLIBS     += -llog -ldl -lm -latomic -L$(LOCAL_PATH)/libs/armeabi  
                          - L$(LOCAL_PATH)/libs/armeabi-v7a  -L$(LOCAL_PATH)/libs/mips 
                           -L$(LOCAL_PATH)/libs/x86  -L$(LOCAL_PATH)/libs/arm64-v8a 
 LOCAL_CPPFLAGS += -ljnigraphics -D_LINUX  -DBOOST_HAS_PTHREADS -fexceptions -std=c++11 
                                 -I$(LOCAL_PATH)/  -I$(LOCAL_PATH)/library/lib/pico/ I
LOCAL_CPP_FEATURES :=  exceptions rtti
APP_OPTIM := debug

When I compile the Android app with Android NDK r10e. I hav the next errores in the Log:

error: undefined reference to
'cv::DescriptorMatcher::match(cv::_InputArray const&,    cv::_InputArray const&, std::__1::vector<cv::DMatch, std::__1::allocator<cv::DMatch> >&, cv::_InputArray const&) const'

  undefined reference to 'cv::Subdiv2D::insert(std::__1::vector<cv::Point_<float>,std::__1::allocator<cv::Point_<float> > > const&)'

 error: undefined reference to 'cv::imwrite(cv::String const&, cv::_InputArray const&, std::__1::vector<int,  std::__1::allocator<int> > const&)'

the undefined reference to cv::imwrite method, this method is in the native SDK opencv in the path "opencv/imgcodecs.hpp"

CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
          const std::vector<int>& params = std::vector<int>());