Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost] Going insane trying to build boost for android
From: Robert Dailey (rcdailey.lists_at_[hidden])
Date: 2017-03-28 23:29:12


On Tue, Mar 28, 2017 at 8:39 AM, Robert Dailey <rcdailey.lists_at_[hidden]> wrote:
> On Tue, Mar 28, 2017 at 3:10 AM, John Maddock <jz.maddock_at_[hidden]> wrote:
>>
>> Right, but that built with g++ not clang++.
>
> Doh!!! I didn't even notice this. Crap. I'll fix it when I get home
> and try again.
>
>> I don't think Boost.Build does anything "different" here: it basically just
>> invokes clang++.
>>
>> Note that clang is not particular "bright" in the way it creates it's
>> wrapper headers around <cstdlib> etc. Last time I had an issue like this,
>> the missing symbol was present in the system headers, but guarded by a
>> #ifdef that clang didn't define (where as GCC did)..... OK had a quick
>> Google, and that symbol is protected by a clang "availability" macro:
>>
>> longdoublestrtold(constchar*,char**)__INTRODUCED_IN(21);
>>
>> So it seems to me that this error will be generated by any attempt to
>> compile with clang unless you specify some "magic" command line option to
>> tell it to use the latest android API? No idea what that would be, but
>> perhaps you do?
>>
>> Hopefully getting closer, John.
>
> Thanks for the help. Looks like it is expecting API 21 to be used.
> Which is strange because the NDK documentation says to use the minimum
> supported API you intend to use. Which is 15 for me. But just grepping
> the NDK source directories, I see that certain files/symbols are only
> defined starting at API 21. I think a lot of the C library headers are
> provided by the target API directory, and they change it with each
> version.
>
> I'll try 21 and see if I get different results, and hopefully it won't
> break when running on Android Ice Cream Sandwich (API 15)

So I corrected my ndk test in CMake, and it now builds properly with clang++:

$ ninja -v
[1/2] C:\android\ndk\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe
--target=armv7-none-linux-androideabi
--gcc-toolchain=C:/android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/android/ndk/platforms/android-15/arch-arm
-Dndk_test_EXPORTS -isystem
C:/android/ndk/sources/cxx-stl/llvm-libc++/include -isystem
C:/android/ndk/sources/android/support/include -isystem
C:/android/ndk/sources/cxx-stl/llvm-libc++abi/include -isystem
C:/android/ndk/platforms/android-15/arch-arm/usr/include
-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp
-funwind-tables -no-canonical-prefixes -fexceptions -frtti -g -fPIC
-std=gnu++14 -MD -MT CMakeFiles/ndk_test.dir/main.cpp.o -MF
CMakeFiles\ndk_test.dir\main.cpp.o.d -o
CMakeFiles/ndk_test.dir/main.cpp.o -c ../main.cpp
[2/2] cmd.exe /C "cd . &&
C:\android\ndk\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe
--target=armv7-none-linux-androideabi
--gcc-toolchain=C:/android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/android/ndk/platforms/android-15/arch-arm -fPIC
-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp
-funwind-tables -no-canonical-prefixes -fexceptions -frtti -g
-Wl,--fix-cortex-a8 -shared -Wl,-soname,libndk_test.so -o
libndk_test.so CMakeFiles/ndk_test.dir/main.cpp.o
"C:/android/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a"
"C:/android/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++abi.a"
"C:/android/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libandroid_support.a"
"C:/android/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libunwind.a"
-latomic && cd ."

I'm still not able to build boost though. I did try switching to API
21 but I get a different set of errors:

In file included from libs\atomic\src\lockpool.cpp:16:
In file included from .\boost/config.hpp:57:
In file included from .\boost/config/platform/linux.hpp:74:
In file included from .\boost/config/posix_features.hpp:18:
In file included from
C:/android/ndk/platforms/android-21/arch-arm/usr/include\unistd.h:34:
In file included from
C:/android/ndk/platforms/android-21/arch-arm/usr/include\sys/select.h:35:
C:/android/ndk/platforms/android-21/arch-arm/usr/include\signal.h:86:18:
error: expected ';' at end of declaration list
    sighandler_t sa_handler;
                 ^
C:/android/ndk/platforms/android-21/arch-arm/usr/include\asm/signal.h:101:22:
note: expanded from macro 'sa_handler'
#define sa_handler _u._sa_handler
                     ^


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net