Ask Your Question

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

asked 2016-01-07 13:51:42 -0500

fah127 gravatar image

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>());
edit retag flag offensive close merge delete


Hi, Have you got any solution to use c++_static or c++_shared as APP_STL? 'gnustl_static' is no longer supported by NDK

Sar gravatar imageSar ( 2018-10-19 00:29:06 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-29 05:23:18 -0500

AsparaJoe gravatar image

updated 2017-01-29 16:29:14 -0500

I had the same error on imwrite and changing APP_STL := gnustl_static to APP_STL := c++_shared (or APP_STL := c++_static) in my does the trick for me

edit flag offensive delete link more


I have the same error. Has anyone solved this error?

monxarat gravatar imagemonxarat ( 2018-09-02 22:56:41 -0500 )edit

Question Tools

1 follower


Asked: 2016-01-07 13:40:19 -0500

Seen: 1,982 times

Last updated: Sep 02 '18