Opened 7 years ago

Closed 7 years ago

#11526 closed Feature Requests (fixed)

mbtowc and wctomb are not implemented on Android

Reported by: jeff.diclemente@… Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost Development Trunk Severity: Problem
Keywords: Android Cc:

Description

A runtime error occurs when using the Boost serialization library on Android. The symbols "mbtowc" and "mctomb" cannot be found by the linker. This occurs because the GNU C++ library provided by the Android NDK does not implement mbtowc and wctomb.

A working example which demonstrates this error is attached. It is taken verbatim from the boost serialization example (i.e. boost/libs/serialization/examples/demo_xml.cpp). It can only be run on an Android device.

The example program was built using the following: arm-linux-androideabi-g++ demo_xml.cpp -Iboost/include -std=c++11 -Lboost/lib -lboost_wserialization -lboost_serialization

The example program was built using a standalone GCC 4.8.0 ARM-v7a toolchain built from Android NDK r9 using boost 1.49.0. The issue still exists in the latest boost code in GitHub and with the latest Android NDK r10e (i.e. the C++ Library in Android NDK r10e was examined and "mbtowc" and "wctomb" still don't exist).

To reproduce, build a standalone GCC toolchain for ARM-v7a by following the instructions here: https://developer.android.com/ndk/guides/standalone_toolchain.html and then build ./boost/libs/serialization/examples/demo_xml.cpp.

I have a proposed fix for this which uses mbrtowc and wcrtomb, which are supported by the Android C++ library. I plan to submit a GitHub pull request.

Change History (2)

comment:1 by jeff.diclemente@…, 7 years ago

Unable to attach a working binary example as it exceeds the size limit. Nonetheless, the binary was built from example code (./boost/libs/serialization/examples/demo_xml.cpp) found within the boost serialization library and demonstrates the issue.

comment:2 by Robert Ramey, 7 years ago

Resolution: fixed
Status: newclosed

this should be fixed now that we use mbrtowc and friends.

Note: See TracTickets for help on using tickets.