NDK(18)eclipse 使用C++ STL
1.引用库
在Application.mk 中使用 APP_STL := stlport_static 等.
1 APP_ABI := x86 armeabi 2 APP_PLATFORM := android-15 3 4 #APP_STL := gnustl_static #GNU STL 5 APP_STL := stlport_static 6 APP_CPPFLAGS := -fexceptions -frtti #允许异常功能,及运行时类型识别 7 APP_CPPFLAGS +=-std=c++11 #允许使用c++11的函数等功能 8 APP_CPPFLAGS += -frtti #开启RTTI 9 #APP_CPPFLAGS +=-fpermissive #此项有效时表示宽松的编译形式,比如没有用到的代码中有错误也可以通过编译; 10 #使用GNU STL时不用此项std::string 居然编译不通过!!
APP_STL 的取值有 : 推荐使用 stlport_static
1 system -> Use the default minimal system C++ runtime library. 2 gabi++_static -> Use the GAbi++ runtime as a static library. 3 gabi++_shared -> Use the GAbi++ runtime as a shared library. 4 stlport_static -> Use the STLport runtime as a static library. 5 stlport_shared -> Use the STLport runtime as a shared library. 6 gnustl_static -> Use the GNU STL as a static library. 7 gnustl_shared -> Use the GNU STL as a shared library. 8 c++_static -> Use the LLVM libc++ as a static library. 9 c++_shared -> Use the LLVM libc++ as a shared library.
2.加入头文件
右键项目,Properties ... 加入stl头文件 的include
/home/admin/Android/android-ndk-r10e/sources/cxx-stl/stlport/stlport/
3.使用
使用,注意,这里用的是静态方式,如用动态的,那么要在java中
static{ System.loadLibrary("stl的库"); }