Android NDK C++ 'wstring' support

2020-06-16 03:48发布

问题:

I have source code/lib written in C++ - now i would like to compile and use the same in Android NDK project (NDK 6). I am able to compile most of the C++ files except "std::wstring" based functionality.

In Application.mk when i specify APP_STL: = stlport_static then it compiles std::wstring based code but when i specify APP_STL: = gnustl_static it fails to compile. I do not know how to resolve std::wstring related issue with APP_STL: = gnustl_static

Any pointer or help on this would be greatly appreciated.

回答1:

A very similar question has already been asked: android-ndk gnustl_static exe not working consider looking at that question and testing to see if any of those answers work.



回答2:

When I hit this exact problem, I saw the general disdain for wchar_t and decided to stop using it. So std::wstring became std::basic_string<uint_32>. I also had to rework some wide character string literals. It's not an ideal solution but it does address all future portability concerns.