简体   繁体   中英

Android NDK clang compiler can't find std::make_unique

I'm using Android NDK r10d. My application.mk is setup like so:

APP_CFLAGS := -DANDROID -DBUILD_OGLES2
APP_CPPFLAGS := $(APP_CFLAGS) -fexceptions -frtti -std=c++14
APP_STL := gnustl_static
APP_ABI := armeabi-v7a
APP_PLATFORM := android-15
NDK_TOOLCHAIN_VERSION := clang

I am using std::make_unique in my code and it isn't compiling (says it isn't found). This feature should be available in STL starting with C++14. I did some poking around and it seems that clang isn't using GNU STL 4.9 in the NDK. If it were, it would be available since I see it inside <memory> header.

What am I missing here? Is there a way to use 4.9 GNU STL with clang?

make_unique isn't available through gnustl from clang. You can try using LLVM libc++ instead. Set this inside your Application.mk :

APP_STL := c++_static
NDK_TOOLCHAIN_VERSION := clang

edit: Forcing the use of GNU STL 4.9 (by changing TOOLCHAIN_VERSION inside android-ndk-r10d/toolchains/*toolchain_name*-clang3.5/setup.mk ) makes the build crash:

clang++: /s/ndk-toolchain/src/llvm-3.5/llvm/tools/clang/lib/AST/DeclBase.cpp:1293: clang::DeclContext::lookup_result clang::DeclContext::lookup(clang::DeclarationName): Assertion 'DeclKind != Decl::LinkageSpec && "Should not perform lookups into linkage specs!"' failed.

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