Can you use std::string in the NDK?

3,142 views
Skip to first unread message

draffodx

unread,
Apr 23, 2010, 12:32:21 PM4/23/10
to android-ndk
I am completely new to C++ but I've been asked to port some windows
mobile C++ to basic ANSI C++

I have been reading up on C++ and learning as best I can as I port the
code.

Googling issues as I hit them.

But this one issue has been slowing me up a while now and I need help
as the solutions Google threw up are not working

Here is my code

//charString.h

]#ifndef CHARSTRING_H
#define CHARSTRING_H

#include <string>


std::string my_string("");
static char* EmptyString=my_string;

classes...
{
};


#endif

And the GCC compiler errors:

CharString.h:26: error: 'string' in namespace 'std' does not name a
type
CharString.h:27: error: 'my_string' was not declared in this scope

I have tried everything Google threw up including using namespace std
and other combinations.

So I was wondering if its to do with the libraries in the NDK, but
string is in there and from reading up its part of basic C++ so should
work in the NDK or am I wrong?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

mic _

unread,
Apr 23, 2010, 12:40:12 PM4/23/10
to andro...@googlegroups.com
Check out http://www.crystax.net/android/ndk-r3.php
There you can get a customized version of the NDK that has support for C++ standard library stuff.

/Michael

draffodx

unread,
Apr 23, 2010, 12:48:26 PM4/23/10
to android-ndk
Hi Mike,

Thanks for that.

But I think std::string should be available with the Stabdard Library
Template classes?

If not then how stable is the customized NDK you pointed to? I am
working on a commercial App that has to work across all Android
versions and devices without breaking

On Apr 23, 5:40 pm, mic _ <micol...@gmail.com> wrote:
> Check outhttp://www.crystax.net/android/ndk-r3.php
> > android-ndk...@googlegroups.com<android-ndk%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-ndk?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/android-ndk?hl=en.

mic _

unread,
Apr 23, 2010, 12:57:58 PM4/23/10
to andro...@googlegroups.com
That's the point: the standard NDK doesn't have STL support. The custom one (CrystaX) does.
You can read more about CrystaX at its website, but it's basically a custom build of the official NDK sources, with added support for STL, C++ exception etc. Iirc it's fully compatible with all devices. There's a link on the website to a discussion between the author and some google employees if you want more details on what the potential incompabilities used to be and how he fixed them.

/Michael
Reply all
Reply to author
Forward
0 new messages