How to implement mbtowc for Android? (or, ideally, how not?)

I am trying to create an android application that uses boost serialization. I created a library against NDK r8d using a 4.7 g ++ arm. However, when I am going to compile my own code into the library using ndk-build, I get the link "undefined to the link" mbtowc "and" undefined to the link "wctomb" when the compiler tries to link some code to the header archive in boost.

I cannot get a clear answer about whether the NDK supports these features.

Despite the fact that it implements functions, CrystaX NDK is not an option, since it knows about failures when using with Boost according to the Boost mailing list.

So, if the NDK somehow implements these functions, why can't the NDK-build communicate with them? I can find a link to them in cstdlib in the NDK, and I believe that a flag can be set that I need to set, but I'm not sure how and where to do it.

If not, does anyone have any tips on how I can write them? I know something about what mbtowc and its add-on should do, but without much experience writing a low-level C and without much knowledge of the Android / ARM architecture, I could really use some tips on this.

+4
source share
3 answers

Results! Yes, boost has options for creating it without the need for wchar support, adding preprocessor definitions to boost build scripts. Boost is still crashing when building using them in a line of code where I am trying to serialize an object to a file. (the crash is a general segfault at 0x00000000, and I could not get any useful information).

So, I was not worried about writing wctomb or its reverse. I do not need, this is the answer to my question, although ultimately the answer to the question does not matter.

To clarify: don't worry about what I was trying to do. If you use the Boost serialization library and want your code to run on android ndk r8d or earlier, just give up. Write the serializer yourself, because there is no useful information on how to do serialization. I hope this issue is fixed in a future release of ndk, but so far I have no choice but to simply rewrite everything.

+1
source
#ifdef ANDROID int wctomb(char *s, wchar_t wc) { return wcrtomb(s,wc,NULL); } int mbtowc(wchar_t *pwc, const char *s, size_t n) { return mbrtowc(pwc, s, n, NULL); } #endif 
+8
source

I had the same problem. I created an android port for code that uses boost :: serialization.

My code could not be compiled due to the lack of implementation of mbtowc / wctomb (mb: multi-byte (char), wc: (wide-char) '

The implementation of these functions is likely to be a difficult reason, since, as far as I know, for for android uses one byte of char instead of a true wide character.

However, when I compiled boost with -DBOOST_NO_STD_WSTRING , the link errors disappeared and I could use boost::archive::text_iarchive and boost::archive::text_oarchive on android.

Now I am serializing STL containers with numbers and std :: strings without any problems.

I compiled boost for android following the tips at this link: http://www.codexperiments.com/android/2011/05/tips-tricks-building-boost-with-ndk-r5/

I am using boost-1.55_0 and NDK r9c.

I added the following <compileflags>-DBOOST_NO_STD_WSTRING command to the build command so that it <compileflags>-DBOOST_NO_STD_WSTRING serialization library without wide character support.

0
source

All Articles