简体   繁体   中英

Android NDK C++ stlport

Currently I'm using NDK-r10c with C++11 support through gnustl. Unfortunately our project need to switch to stlport. While changing from gnustl to stlport many errors raised during compilation. Below is Application.mk file.

APP_PLATFORM            := android-18 
NDK_TOOLCHAIN_VERSION   := 4.8 
APP_ABI                 := armeabi-v7a 
APP_STL                 := stlport_static
# APP_STL               := gnustl_static 
APP_CPPFLAGS            := -std=c++11 
ifeq ($(NDK_DEBUG),1) 
APP_OPTIM               := debug 
else 
APP_OPTIM               := release
endif

It seems that C++11 features are not available: - cbegin(), cend() on vectors - data() on vectors, - cannot deduce auto from cbegin(), etc.

STLport is just too old and does not support C++11 at all.

Flags like -std=c++11 will affect the compiler only, not necessarily the STL implementation.

You will have to use either gnustl or libc++

To use stlport you will need add these lines in your Android.mk

# Need this line to allow use alloc on stl containers
LOCAL_CFLAGS := -D_STLP_USE_NEWALLOC

# c++11 support
LOCAL_CPPFLAGS += -std=c++11

# for stl port
LOCAL_LDLIBS    += -lstdc++

# include stl headers
LOCAL_C_INCLUDES += ${NDK_ROOT}/sources/cxx-stl/stlport/stlport

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM