Boost logo

Boost :

Subject: Re: [boost] [filesystem] Please take care of #8706
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-07-10 02:58:36


2013/7/9 Augusto Righetto <augustorighetto_at_[hidden]>

> After some investigation, I've figured out that the crash only happens when
> my app links dynamically against boost_system and boost_filesystem.
> Everything works fine when I link statically.
>

I was having almost the same problems a few weeks ago. When you link
dynamically against Boost libraries you must also link dynamically against
gnustl_shared. In that case neither Boost not your application must links
against static version of gnustl.

> I'm building boost using a standalone toolchain built with NDK 8e 64-bit.
> The toolchain is targeted to android-14 (actually, android-9 since it is
> the
> highest platform available on NDK 8e).
>
> My app is linking statically against GNU STL (libstdc++) and supc++
> (enabling exceptions).

You must not mix static and shared versions of STL. If you are using at
least one dynamic library - than you need to link all your libraries and
executables agains dynamic version of STL. Otherwise program won't work.
That is because of some global variables inside STL - if you link STL
statically to multiple *.so, then each *.so will have it's own instances of
global variables. While this may sometimes somehow work with defaul Linux
runtime linker, Android has its own linker that won't resolve those
conflicts.

Besides that, I'm enabling -fexceptions and -frtti.
> Following Google's recommendation about ABI compatibility, I'm enabling
> -march=armv7-a, -mfloat-abi=softfp and -mfpu=vfpv3-d16.
>

I also define

<compileflags>-DBOOST_ASIO_DISABLE_STD_ATOMIC # See
https://code.google.com/p/android/issues/detail?id=42735#makechanges
<compileflags>-DBOOST_AC_USE_PTHREADS # See
https://code.google.com/p/android/issues/detail?id=42735#makechanges
<cxxflags>-D_REENTRANT
<cxxflags>-D_GLIBCXX__PTHREADS
<compileflags>-D__ARM_ARCH_5__
<compileflags>-D__ARM_ARCH_5T__
<compileflags>-D__ARM_ARCH_5E__
<compileflags>-D__ARM_ARCH_5TE__

I'm using Android's engineering build, so I'm able to run the Boost's
> Filesystem test apps directly on device without any Java/Dalvik code.
>
> Did you try to build and link Boost as a shared library?
>

I tried that, but failed. Shared libraries could not link against -lrt
(because it does not exists under Android) and some unresolved symbols. So
I thought to take care of static builds first.

If you succeeded in making dynamic versions of Boost libraries, please tell
me how to do it.

-- 
Best regards,
Antony Polukhin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk