问题描述
我正在使用Android Studio 1.3.2 + ndk-r11b-windows-x86_64,并尝试使用本机代码和C ++ 11功能(share_ptr,weak_ptr等)构建项目,但出现了一些错误.例如:
I'm using Android studio 1.3.2+ndk-r11b-windows-x86_64 and try to build project with native code and C++11 features (share_ptr, weak_ptr and etc.) but got some errors. For example:
问题是:如何在Android Studio + NDK中使用C ++ 11?
The issue is: how to use C++11 with Android Studio+NDK?
p.s.我将标志cppFlags.add ("-std=c++11")
添加到了"build.gradle"
p.s.I added flag cppFlags.add ("-std=c++11")
into "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"
}
但是似乎没有用.
推荐答案
在应用程序的build.gradle文件中,我转到android-> defaultConfig-> externalNativeBuild-> cmake,然后从中编辑cppFlags参数
On build.gradle file of the App I go to android -> defaultConfig -> externalNativeBuild -> cmake and I edit the cppFlags parameter from this
cppFlags ""
对此
cppFlags "-std=c++11"
这篇关于如何为Android Studio启用C ++ 11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!