Ask Your Question
0

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

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

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

Application.mk

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
NDK_TOOLCHAIN_VERSION := 4.9

Android.mk

LOCAL_PATH := $(call my-dir)
LOCAL_PATH_LIB_DIR:=library/lib/classifier



include $(CLEAR_VARS)


OPENCV_CAMERA_MODULES:=off
OPENCV_INSTALL_MODULES:=on

OPENCV_LIB_TYPE:=SHARED
include ../../../OpenCV-android-sdk/sdk/native/jni/OpenCV.mk

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_C_INCLUDES += $(LOCAL_PATH)
 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 
                           -L$(LOCAL_PATH)/libs/mips64
                           -L$(LOCAL_PATH)/libs/x86_64
 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
include $(BUILD_SHARED_LIBRARY)

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

Comments

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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

AsparaJoe gravatar image

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

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 Application.mk does the trick for me

edit flag offensive delete link more

Comments

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

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

Question Tools

1 follower

Stats

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

Seen: 2,246 times

Last updated: Sep 02 '18