Building boost with clang

379 views
Skip to first unread message

John Morman

unread,
Jan 4, 2016, 3:08:08 PM1/4/16
to android-ndk
Has anyone successfully built boost using clang? I've successfully built boost using gcc, but with the recent news that gcc support is being deprecated I figured I would try to build boost with clang.

I am using a custom toolchain (clang 3.6, API 19, libc++, arm). I am also building on a Mac.

Whenever I try to build the atomic or filesystem module I get the following error

/Users/john/AndroidToolchain/clang_19_arm_libc/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../sysroot/usr/lib/../lib/crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main'


I am also trying to build the date_time module and get the above error + this new one

/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/atomic:922: error: undefined reference to '__atomic_fetch_add_4'


Has anyone seen these errors and have any experience in fixing them? If not has anyone successfully built boost using clang using a different method? If so could they please share it?

Thanks,
John



mic _

unread,
Jan 7, 2016, 7:17:16 AM1/7/16
to andro...@googlegroups.com
>Has anyone successfully built boost using clang?

Yes. I've built Boost 1.48 and 1.55 with the NDK using Clang 3.4, 3.5 (and IIRC, 3.6). I'm not using Boost.Build (b2); instead I wrote Android.mk files for each non-include-only boost library that I wanted to build, and then a master Android.mk that simply calls the other Android.mk files.


>Whenever I try to build the atomic or filesystem module I get the following error
>/Users/john/AndroidToolchain/clang_19_arm_libc/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../sysroot/usr/lib/../lib/crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main'

How are you attempting to build the library exactly?


>I am also trying to build the date_time module and get the above error + this new one
>
>/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/atomic:922: error: undefined reference to '__atomic_fetch_add_4'

Do you have -latomic in your LOCAL_LDFLAGS? Note that if you're building for armeabi you're probably going to have to set some additional flags in your boost makefile(s) (e.g. BOOST_AC_USE_PTHREADS, BOOST_SP_USE_PTHREADS, and possibly some others).

/Michael

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.

John Morman

unread,
Jan 7, 2016, 11:19:14 AM1/7/16
to android-ndk
I was building with b2 since I was able to get gcc to successfully work with that. I'll look into writing Android.mk files instead though if that seems to work for you. And good call on -latomic, I probably forgot to add that. One interesting note is that if I specify the link=static flag to b2 then most the modules seem to be building fine. Only trying to build dynamic libraries throws the errors above (This definitely makes sense for the atomic error since I wouldn't see that till I actually compile my .so file that needs atomics).

Thanks,
John

mic _

unread,
Jan 7, 2016, 11:23:31 AM1/7/16
to andro...@googlegroups.com
>One interesting note is that if I specify the link=static flag to b2 then most the modules seem to be building fine.

I'm building static libraries out of the boost libraries. I then link these to my "main" module where I build my shared object.

/Michael
Reply all
Reply to author
Forward
0 new messages