Does anyone have experience building Cereal on Android?

390 views
Skip to first unread message

Dima Korolev

unread,
Dec 18, 2014, 3:44:33 AM12/18/14
to cere...@googlegroups.com
Hello,

Trying to build Cereal for Android. Am I right assuming that the dependency on __cxa_demangle is critical?

If no, how plausible would it be to work around it?
If yes, is there a reliable way to link against a custom one on Android in a way that does not break in the future?

Thanks,
Dima

David Irvine

unread,
Dec 18, 2014, 4:35:36 AM12/18/14
to Dima Korolev, cere...@googlegroups.com, Spandan A

On Thu, Dec 18, 2014 at 8:44 AM, Dima Korolev <dmitry....@gmail.com> wrote:
Trying to build Cereal for Android. Am I right assuming that the dependency on __cxa_demangle is critical?

We have built cereal on Android. I have copied Spandan to try and help you. (hope that's OK Spandan)


--

David Irvine
twitter: @metaquestions

athos bacchiocchi

unread,
Jan 24, 2015, 11:55:59 PM1/24/15
to cere...@googlegroups.com, dmitry....@gmail.com, span...@karyatech.com

On Thursday, 18 December 2014 10:35:36 UTC+1, David Irvine wrote:
We have built cereal on Android. I have copied Spandan to try and help you. (hope that's OK Spandan)

I had the same issue. Solved using ndk r10d.

Roberto Garrido

unread,
Mar 9, 2015, 3:53:27 AM3/9/15
to cere...@googlegroups.com, dmitry....@gmail.com, span...@karyatech.com
Hi, I'm trying to build CEREAL for Android too. I'm using r10d ndk version, and the android cmake toolchain file from the android-cmake (https://github.com/taka-no-me/android-cmake) project.
I can run the cmake configure and generate steps without errors, but when I build the project with the command line using make, it complains about std::to_string not found:

cereal.hpp:641:101: error: 'to_string' is not a member of 'std'

I have dedicated a lot of time to this issue, so any help would be much appreciated.

Robert.

Dima Korolev

unread,
Mar 9, 2015, 4:02:17 AM3/9/15
to Roberto Garrido, cere...@googlegroups.com, span...@karyatech.com
W/o context, --std=c++11 is likely the solution.

Roberto Garrido

unread,
Mar 9, 2015, 4:15:07 AM3/9/15
to cere...@googlegroups.com, robertogar...@gmail.com, span...@karyatech.com


On Monday, 9 March 2015 09:02:17 UTC+1, Dima Korolev wrote:
W/o context, --std=c++11 is likely the solution.


Thanks, 
The root CMakeLists.txt file contains a line adding that switch:
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Werror -g -Wextra -Wshadow -pedantic ${CMAKE_CXX_FLAGS}")

If I set VERBOSE=1 when I run make, I can see the that switch there.
Any other ideas?
What else do you need to know? I'm on Mac OSX Mavericks.

Thanks,
Robert.

Roberto Garrido

unread,
Mar 9, 2015, 4:27:22 AM3/9/15
to cere...@googlegroups.com, robertogar...@gmail.com, span...@karyatech.com
Maybe you can share the toolchain file you used?

Thanks,
Robert.

Erich Keane

unread,
Mar 9, 2015, 11:49:16 AM3/9/15
to cere...@googlegroups.com
Unfortunately, Android's standard library (particularly in older versions) is missing a large number of stanard library functions.  It can be worked around by putting the following above your "#include <cereal.hpp>" in your consuming app:

#ifdef __ANDROID // note, this define might be different in your system, if you are doing android ONLY you can exclude the ifdef.
#include android.h
#endif

Then, create android.h with the following:

#include <iostream>
namespace std
{
    template<typename T>
    std::string to_string(T item)
    {
        ostringstream sstr;
        sstr << item;
        return sstr.str();

Roberto Garrido

unread,
Mar 9, 2015, 12:09:31 PM3/9/15
to cere...@googlegroups.com


On Monday, 9 March 2015 16:49:16 UTC+1, Erich Keane wrote:
Unfortunately, Android's standard library (particularly in older versions) is missing a large number of stanard library functions.  It can be worked around by putting the following above your "#include <cereal.hpp>" in your consuming app:

#ifdef __ANDROID // note, this define might be different in your system, if you are doing android ONLY you can exclude the ifdef.
#include android.h
#endif

Then, create android.h with the following:

#include <iostream>
namespace std
{
    template<typename T>
    std::string to_string(T item)
    {
        ostringstream sstr;
        sstr << item;
        return sstr.str();
    }
}



Hi Erich, thanks for pointing to the right direction.
You forgot to add the quotation marks in #include "android.h", and also to add #include <sstream> in the android.h file itself.
Now it works.

¡Thank you!
 

Erich Keane

unread,
Mar 9, 2015, 12:12:08 PM3/9/15
to cere...@googlegroups.com
Sorry about that, I was typing from memory :)  Glad I could help!
-Erich

Roberto Garrido

unread,
Mar 9, 2015, 12:12:46 PM3/9/15
to cere...@googlegroups.com
Hey, you did perform very well ;)

Robin Tan

unread,
Dec 22, 2016, 2:11:00 AM12/22/16
to cereal serialization library
I'm trying to compile on Android as well, I did this already and still getting more errors like stoll is not a member. Is there a offical solution for this already, or do I have to define all the std functions?

Robin
Reply all
Reply to author
Forward
0 new messages