Import STL libraries to the Android NDK code
来源:互联网 发布:pe我的世界矿物追踪js 编辑:程序博客网 时间:2024/06/09 23:51
This is a quick tip for those who are beginning to write native Android code. As one may have noticed, it isn’t possible to use containers like, string, vector, list inside the NDK samples. These are all part of the STL (Standard Template Library), and are expected to be available when writing C++ code.
To add STL to your NDK code, locate the Application.mk file inside your project’s jni folder. If it isn’t there, create it. Please note that the Application.mk is not the Android.mk file! The Android.mk file instructs the compiler and the JNI on how NDK code should be handled. The Application.mk, works similarly as the Android manifest file for your NDK code, allowing the programmer to add permissions and define other applications’ properties, like such as ‘enabling’ the STL support.
After creating the Application.mk, add this line of code:
- APP_STL := stlport_static
Now at the .c or .cpp file or at the header of the class where STL needs to be included, add the following:
- //to use strings
- #include <string>
- //to use vectors
- #include <vector>
- //and so on...
- /* add this line, to avoiding writing 'std::' every time a string (or any
- other container) is declared.*/
- using namespace std;
This was tested using Android NDK, Revision 5b, released in January 2011. I don’t know if works on previous version of the NDK.
- Import STL libraries to the Android NDK code
- How to include <android/bitmap.h> and other *.h NDK libraries to Titanium Android module?
- android ndk Using Existing Libraries
- android ndk Using Prebuilt Libraries
- android studio导入eclipse的library/ import libraries from eclipse to android studio
- How to Render Image Buffer in Android NDK Native Code
- How to Render Image Buffer in Android NDK Native Code
- Using Android Studio to build applications with NDK and Boost C++ libraries
- Debug Android NDK code
- Android NDK 使用 STL
- android NDK STL 支持
- Building Open Source libraries with Android NDK
- Releasing the Source Code for the .NET Framework Libraries
- Releasing the Source Code for the .NET Framework Libraries
- Introduction to the Winpcap Networking Libraries
- Unable to find the ncurses libraries
- Unable to find the Ncurses libraries.
- NDK do not find the standard C++ libraries
- React-Redux学习文档v1
- ARCGIS种通过三参数和其参数进行精确投影转换
- android应用开发-从设计到实现 4-10 解析天气预报数据
- C#中事件方法的使用
- widget添加
- Import STL libraries to the Android NDK code
- 快速掌握和使用Flyway
- applicationContext.xml加载的两种方式:
- zookeeper与etcd
- Ajax发送post请求
- 【hibernate】Attribute "column" must be declared for element type "property"解决办法
- 泛型
- eclipse设置界面、字体、导入项目
- web监听器