Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: 'to_string' is not a member of 'std'

It could be duplicate, but I tried all the solutions that I found on and out StackOverflow.

I'm making a library on C++ with OpenCV and trying to compile it for Android.

I can't use to_string(int)but I'm not able. I tried to modify my makefile too many times. My last configuration is this on:

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_CAMERA_MODULES:=off

OPENCV_INSTALL_MODULES:=on

include $(LOCAL_PATH)/jsoncpp/Android.mk

include /Users/rafaelruizmunoz/Desktop/AndroidDevelopment/OpenCV-2.4.9-android- sdk/sdk/native/jni/OpenCV.mk

OPENCV_LIB_TYPE:=SHARED

LOCAL_C_INCLUDES += $(LOCAL_PATH)

LOCAL_C_INCLUDES += /Users/rafaelruizmunoz/opencvscan/OpenCVtry/

LOCAL_C_INCLUDES += /Users/rafaelruizmunoz/Desktop/RD/OpenCVtry/Libraries/jsoncpp- master/include

LOCAL_PATH := jni

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

LOCAL_MODULE := libXYZ

LOCAL_MODULE_NAME := mylibXYZ

LOCAL_SRC_FILES := androidClass.cpp main.cpp utils.cpp

LOCAL_LDLIBS += -llog -ldl

LOCAL_CPPFLAGS := -std=c++11 CFLAGS=-g -Wall -Wextra -std=c++11 -Wno-write-strings ../../include/boost

LOCAL_SHARED_LIBRARIES := libJsoncpp libopencv_java

include $(BUILD_SHARED_LIBRARY)

and this is my Application.mk

APP_STL := gnustl_static

APP_CPPFLAGS := -frtti -fexceptions

APP_ABI := all

APP_MODULES := libXYZ libJsoncpp

APP_CPPFLAGS := -std=gnu++0x

APP_CPPFLAGS += -frtti

APP_CPPFLAGS += -fexceptions

APP_CPPFLAGS += -DDEBUG

APP_CPPFLAGS += -std=c++11

NDK_TOOLCHAIN_VERSION := 4.8

LOCAL_C_INCLUDES += ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/include

APP_USE_CPP0X := true

Thanks in advance.

like image 580
Rafael Ruiz Muñoz Avatar asked Sep 29 '14 08:09

Rafael Ruiz Muñoz


1 Answers

I ran into this issue too. to_string is not available in gnu-libstdc++ "out of the box". I searched the sources and found that std::to_string is indeed in the lib (sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h) but opted out by

#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
     && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))

After adding -D_GLIBCXX_USE_C99 to the build std::to_string is opted in.

like image 199
hutorny Avatar answered Oct 04 '22 12:10

hutorny