STL library - STLport or GNU libstdc++?

748 views
Skip to first unread message

Ilya Konstantinov

unread,
May 27, 2014, 9:34:41 PM5/27/14
to andro...@googlegroups.com
Hi,

I'm porting a native app that requires wchar support and STL to Android.
I'm using Dmitry Moskalchuk's (crystax) work for wchar implementations,
and now I'm contemplating on whether to use STLport or libstdc++.

In my particular case, I need -fshort-wchar, which further complicates
matters.

1) STLport comes with a README notice stating it's beta quality
   and in particular, it claims exceptions are not supported.
   Anyone knows what's up with that?
   
   For the record, stlport/stl/config/_android.h does NOT define
   _STLP_NO_EXCEPTIONS.
   
2) Any reason wstring wouldn't work if I rebuild STLport
   with proper, functioning wide string functions?

3) The disadvantage in using libstdc++ is that it has to be built
   as part of a toolchain rebuild, which I prefer to avoid (since
   I want to enable our devs to use Google-maintained NDKs).
   
   Is there a way to build libstdc++ separate from the toolchain?
   The reason for rebuilding is widechar support.

P.S. 
What's with STLport's <stdexcept> only including *forward
declarations* of std::string? I understand the desire to speed up
builds, but this is silly. Doing 'throw runtime_exception("something
broke") and the ensuing 'cannot cast const char* to std::string'
is way confusing, and including <string> to solve this
is counter-intuitive.

(If I end up using STLport, I'll probably have an 'stdexcept' of my own
#include_next'ing theirs and then including <string>.)

J Decker

unread,
May 28, 2014, 12:30:14 AM5/28/14
to andro...@googlegroups.com
If you had working wide char support; you could only use it for reading existing files and rendering; there's no way to get unicode input from the user.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.

David Turner

unread,
May 28, 2014, 4:17:30 AM5/28/14
to andro...@googlegroups.com
Read $NDK/docs/CPLUSPLUS-SUPPORT.html for all the details.

In a nutshell:

1) You can use STLport with exceptions now (requires a recent NDK). However, the library is ancient, upstream maintenance is dead, and it lacks many useful features. I would not recommend it.

2) wchar_t is not fully supported by the system, you could try using the support library under ($NDK/sources/android/support) to get better one though. You'll have to statically link it to your own project files. Not sure how to piggy back libstdc++ on top of it though, the library was specifically written to get libc++ working properly instead (this work isn't completed yet though).

3) Rebuilding the GNU libstdc++ may not be enough to get proper wide char support, since it relies on the C library to actually perform low-level tasks. You can look at "$NDK/build/tools/build-cxx-stl.sh --stl=gnustl" to rebuild it from sources (look at the scripts for things to modify if you need to).


Reply all
Reply to author
Forward
0 new messages