Ticket #6 (accepted task)

Opened 2 years ago

Last modified 10 days ago

Make boost build

Reported by: dmc Owned by: dmc
Priority: major Milestone: r7-crystax-5
Component: ndk Version: r3-crystax-2
Severity: high Keywords:
Cc: ognian Blocked By: 10, 18, 26
Blocking:

Description

We need to get boost libraries (http://www.boost.org/) built for Android. Some start information on how to do that can be found there: http://groups.google.com/group/boost-list/browse_thread/thread/ce2144a2ee9e47f9/f75844dc37f8fd4c

Attachments

user-config.jam (4.2 KB) - added by alan 2 years ago.
user-config.jam for building
boost.patch (2.9 KB) - added by alan 2 years ago.
patch for boost 1.39

Change History

comment:1 Changed 2 years ago by dmc

  • Milestone set to r3-crystax-3

comment:2 Changed 2 years ago by dmc

  • Type changed from enhancement to task

comment:3 Changed 2 years ago by dmc

  • Milestone changed from r3-crystax-3 to r4-crystax-1

comment:4 Changed 2 years ago by dmc

  • Milestone changed from r4-crystax-1 to r4-crystax-2

Changed 2 years ago by alan

user-config.jam for building

comment:5 Changed 2 years ago by alan

I have had some success building boost 1.39 with the attached user-config.jam. I am running bjam with the following command:

bjam --without-python --without-math --without-mpi --without-iostreams toolset=gcc-android4.4.0 link=static runtime-link=static target-os=linux --stagedir=android stage

Changed 2 years ago by alan

patch for boost 1.39

comment:6 Changed 2 years ago by alan

I havent tried running the boost unit tests but have run unit tests for my application which is using boost

comment:7 Changed 23 months ago by dmc

  • Status changed from new to accepted
  • internal set to 0
  • Blocked By set to 10, 18

comment:8 Changed 23 months ago by dmc

  • Milestone changed from r4-crystax-2 to r4-crystax-3

comment:9 Changed 22 months ago by dmc

  • Blocked By changed from 10, 18 to 10, 18, 26

comment:10 Changed 22 months ago by dmc

  • Severity set to high

comment:11 Changed 10 months ago by pelya

https://github.com/MysticTreeGames/Boost-for-Android - Boost 1.45, compiles without any issues with official NDK r5c, however to use boost::spirit you'll need wide chars support and CrystaX NDK r5.

comment:12 follow-up: ↓ 13 Changed 10 months ago by dmc

Thanks, I know this project. It's good and I got some ideas from there. However, it's not enough to get boost compiled; unit/regression tests must be passed too and this is the main problem as of now. There is many parts where boost unit tests failed on android. My goal is to fix such places and release fully working boost distribution for android.

comment:13 in reply to: ↑ 12 Changed 9 months ago by ybereza

Could you tell me which of boost libreries does not pass unit/regression tests?

comment:14 Changed 5 months ago by dmc

  • Milestone r6-crystax-3 deleted

Milestone r6-crystax-3 deleted

comment:15 Changed 10 days ago by halletj

  • Milestone set to r7-crystax-5

This is how I got boost to build, using Google NDK r7,

Compiler
Map the active NDK compiler to Google, using junction or ln

Windows –
junction c:\android-ndk c:\android-ndk-google

Mac OS –
ln –s /android-ndk /android-ndk-google

WCHAR_T

Edit /android-ndk-google/sources/cxx-stl/gnu-libstdc++/include/string
Add the following code to the end of the file,

#if defined(ANDROID)
namespace std
{

typedef long unsigned int wint_t;
typedef basic_string<wchar_t> wstring;

inline int iswspace(wint_t c) { return ::iswspace(c); }
inline int iswpunct(wint_t c) { return ::iswpunct(c); }
inline int iswprint(wint_t c) { return ::iswprint(c); }
inline int iswcntrl(wint_t c) { return ::iswcntrl(c); }
inline int iswupper(wint_t c) { return ::iswupper(c); }
inline int iswlower(wint_t c) { return ::iswlower(c); }
inline int iswalpha(wint_t c) { return ::iswalpha(c); }
inline int iswdigit(wint_t c) { return ::iswdigit(c); }
inline int iswxdigit(wint_t c) { return ::iswxdigit(c); }
inline int towlower(wint_t c) { return ::towlower(c); }
inline int towupper(wint_t c) { return ::towupper(c); }
inline size_t wcslen(const wchar_t *c) { return ::wcslen(c); }

inline size_t wcsxfrm(wchar_t* ws1, const wchar_t* ws2, size_t n) { return ::wcsxfrm(ws1, ws2, n); }
inline long int wcstol(const wchar_t* nptr, wchar_t endptr, int len) { return ::wcstol(nptr, endptr, len); }
inline wchar_t* wcscpy(wchar_t* dest, const wchar_t* src) { return ::wcscpy(dest, src); }
inline int wcscmp(const wchar_t* dest, const wchar_t* src) { return ::wcscmp(dest, src); }

}
#endif

ARMEABI-V7A Support

At the time of writing this Google made a mistake, setting the armeabi-v7a floating point compiler options to “fpvv3”, instead of “fpvv3-d16”, so search and replace all instances of “fpv” in –

• /android-ndk-google/*.mk
• /android-ndk-google/*.sh
• /android-ndk-crystax/*.mk
• /android-ndk-crystax/*.sh

See notes –
http://www.crystax.net/trac/ndk/ticket/68
http://code.google.com/p/android/issues/detail?id=26199

Source

Extract the source from –
• $(WORKSPACE )/oem/android/boost_1_48_0.zip
to –
• $(WORKSPACE)/oem/android/boost_1_48_0

Patch

Patch libs/filesystem/v3/src/operations.cpp:

# include <sys/types.h>
# if !defined(APPLE) && !defined(OpenBSD) && !defined(ANDROID)
# include <sys/statvfs.h>
# define BOOST_STATVFS statvfs
# define BOOST_STATVFS_F_FRSIZE vfs.f_frsize
# elif defined(ANDROID)
# include <sys/vfs.h>
# define BOOST_STATVFS statfs
# define BOOST_STATVFS_F_FRSIZE vfs.f_frsize
# else
# ifdef OpenBSD
# include <sys/param.h>
# endif
# include <sys/mount.h>
# define BOOST_STATVFS statfs
# define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>(vfs.f_bsize)
# endif
# include <dirent.h>
# include <unistd.h>
# include <fcntl.h>
# include <utime.h>
# include "limits.h"

Bootstrapped

cd $(WORKSPACE)/oem/android/boost_1_48_0

./bootstrap.sh --with-libraries=system,filesystem,thread,date_time,regex link=static

User-config.jam

• $(WORKSPACE)/oem/android/boost_1_48_0/tools/build/v2/user-config.jam
import os ;

if [ os.name ] = CYGWIN
[ os.name ] = NT

{

androidPlatform = windows ;

}
else if [ os.name ] = LINUX
{

androidPlatform = linux-x86 ;

}
else if [ os.name ] = MACOSX
{

androidPlatform = darwin-x86 ;

}
modules.poke : NO_BZIP2 : 1 ;
NDK_ROOT = ../../../../../../android-ndk ;

using gcc : android.arm.4.4.3 :
$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :
<compileflags>--sysroot=$(NDK_ROOT)/platforms/android-9/arch-arm
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-fno-strict-aliasing
<compileflags>-O2
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-lstdc++
<compileflags>-I"../../../../../../android-ndk/sources/cxx-stl/gnu-libstdc++/include"
<compileflags>-I"../../../../../../android-ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include"
<compileflags>-DGLIBC
<compileflags>-D_GLIBCPP_USE_WCHAR_T
<compileflags>-DANDROID
<compileflags>-D_LITTLE_ENDIAN
<archiver>$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar
<ranlib>$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib
;

using gcc : android.armv7a.4.4.3 :
$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :
<compileflags>--sysroot=$(NDK_ROOT)/platforms/android-9/arch-arm
<compileflags>-mthumb
<compileflags>-march=armv7-a
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfpv3-d16
<compileflags>-Os
<compileflags>-fno-strict-aliasing
<compileflags>-O2
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-lstdc++
<compileflags>-I"../../../../../../android-ndk/sources/cxx-stl/gnu-libstdc++/include"
<compileflags>-I"../../../../../../android-ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include"
<compileflags>-DGLIBC
<compileflags>-D_GLIBCPP_USE_WCHAR_T
<compileflags>-DANDROID
<compileflags>-D_LITTLE_ENDIAN
<archiver>$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar
<ranlib>$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib
;

using gcc : android.x86.4.4.3 :
$(NDK_ROOT)/toolchains/x86-4.4.3/prebuilt/$(androidPlatform)/bin/i686-android-linux-g++ :
<compileflags>--sysroot=$(NDK_ROOT)/platforms/android-9/arch-x86
<compileflags>-Os
<compileflags>-fno-strict-aliasing
<compileflags>-O2
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-lstdc++
<compileflags>-I"../../../../../../android-ndk/sources/cxx-stl/gnu-libstdc++/include"
<compileflags>-I"../../../../../../android-ndk/sources/cxx-stl/gnu-libstdc++/libs/x86/include"
<compileflags>-DGLIBC
<compileflags>-D_GLIBCPP_USE_WCHAR_T
<compileflags>-DANDROID
<compileflags>-D_LITTLE_ENDIAN
<archiver>$(NDK_ROOT)/toolchains/x86-4.4.3/prebuilt/$(androidPlatform)/bin/i686-android-linux-ar
<ranlib>$(NDK_ROOT)/toolchains/x86-4.4.3/prebuilt/$(androidPlatform)/bin/i686-android-linux-ranlib
;
Build
ARM

./bjam --without-python --without-serialization toolset=gcc-android.arm.4.4.3 link=static runtime-link=static target-os=linux --stagedir=android-arm --disable-filesystem2

ARM-V7A

./bjam --without-python --without-serialization toolset=gcc-android.armv7a.4.4.3 link=static runtime-link=static target-os=linux --stagedir=android-armv7a --disable-filesystem2

X86

./bjam --without-python --without-serialization toolset=gcc-android.x86.4.4.3 link=static runtime-link=static target-os=linux --stagedir=android-x86 --disable-filesystem2

Note: See TracTickets for help on using tickets.