Hi everyone, I’m using Android studio 1.3.2 and am trying to build a project using native code and C ++ 11 features (share_ptr, weak_ptr and etc.), but I get errors. For example:

Error: (22, 6) error: 'shared_ptr' in namespace 'std' does not name a template type

I asked the question here , but so far without an answer.

The problem: How to use C ++ 11 and Android Studio + NDK?

ps I tried to add the cppFlags.add ("-std=c++11") flag cppFlags.add ("-std=c++11") to the project file "build.gradle"

 android.ndk { moduleName = "game" cppFlags.addAll(["-I${file("src/main/jni/native_app_glue")}".toString(), "-I${file("src/main/jni")}".toString(), "-I${file("src/main/jni/data")}".toString()]) cppFlags.add ("-std=c++11") ldLibs.addAll(["android", "EGL", "GLESv2", "OpenSLES", "log"]) stl = "stlport_static" } 

but it doesn't seem to work.

  • What version of ndk do you use? - Vladimir Gamalyan
  • I use android-ndk-r11b-windows-x86_64. - angevad
  • Quite a stupid question, and you connected <memory> where you use shared_ptr? - Unick
  • In previous versions I had to work with, support for c ++ was not so hot (besides, I needed boost and c ++ 14), I ended up using crystax.net - Vladimir Gamalyan
  • Unick, yes I connected <memory> - angevad

1 answer 1

The answer to your question got here . Michael recommended using libc ++ or gnustl. I used gnustl.