How to use the STL library in Android app

Source: Internet
Author: User

Method:

1. Create a new application.mk under the JNI directory; Add App_stl: = Stlport_static to the right of the value can also be replaced by the following:

System-Uses the default minimal C + + runtime, which makes the resulting application small and memory-intensive, but some features will not support

Stlport_static-use STLport as a static library, which is highly recommended by the Android Development Network

Stlport_shared-stlport as a dynamic library, this may produce compatibility and some of the lower versions of the Android firmware, currently not recommended for use.

Gnustl_static-Using the GNU libstdc++ as a static library

By default, STLport does not support C + + exception handling and rtti, so do not appear-fexceptions or-frtti; If you really need to, you can use Gnustl_static to support the features of standard C + +, but the resulting file size will be too large. will run less efficiently.

Support C + + exception handling, add Local_cppflags +=-fexceptions in Application.mk, the same support Rtti, then add Local_cppflags +=-frtti, here again to remind you, The second says use Gnustl static library instead of STLport.

Force recompile STLPort, add Stlport_force_rebuild in application.mk: = True to force recompile STLPort source code, for some reasons may need to modify the next STLPort library, General developers do not need to use this

2. Include the associated header file in the CPP file to use the STL, and use the using namespace Std;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.