Porting a C++ application to android

2019-04-06 09:52发布

问题:

Is it possible to port a C++ application which uses the STL extensively to Android? I understand that currently the NDK does not support this, but is there any effort (open source or otherwise) underway to achieve this?

If not is there a way to cross compile libstdc++ for Android?

UPDATE: Ndk Revision 5 promises a default STL implementation based on STLport. http://android-developers.blogspot.com/2011/01/gingerbread-ndk-awesomeness.html Read this official NDK blog post, http://developer.android.com/sdk/ndk/index.html>and the revision notes.

回答1:

You may want to start with Dmitry Moskalchuk's modified version of the NDK (includes support for exceptions, RTTI, and the standard c++ library). Keep in mind that if you go down this path your application's size will be larger as you will be statically linking a c++ library into it. Also, this thread from the andriod-ndk group may give better direction on how to incorporate the STL.



回答2:

You could always implement what you need yourself. The STL is only written using the CRT, OS headers and standard C++. It would depend on what you need done.