Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 449
void.pointer Avatar asked Mar 12 '15 19:03

void.pointer


1 Answers

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.

like image 177
ph0b Avatar answered Oct 22 '22 10:10

ph0b