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的库");
}

 

posted @   f9q  阅读(547)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 【杂谈】分布式事务——高大上的无用知识?
点击右上角即可分享
微信分享提示