How do I build a fat binary with a standalone toolchain?

690 views
Skip to first unread message

Wil Hadden

unread,
May 1, 2012, 11:33:50 AM5/1/12
to android-ndk
I have gone down the route of using the standalone NDK toolchain to
compile code for android and it works the best.

I can happily create builds for arm7, arm5 and presumably x86 but
could someone explain or point me to a description of how to create a
fat binary using a standalone toolchain?

Thanks
Wil

Chris Stratton

unread,
May 1, 2012, 3:20:53 PM5/1/12
to android-ndk
On May 1, 11:33 am, Wil Hadden <wilhad...@gmail.com> wrote:
> I can happily create builds for arm7, arm5 and presumably x86 but
> could someone explain or point me to a description of how to create a
> fat binary using a standalone toolchain?

AFAIK 'fat binary' is a bit of misnomer on Android - the normal ndk
toolchain creates one distinct .so per ABI listed in the Android.mk,
and copies them all to where the packager will combine them in a
single APK so that the device can install whichever is appropriate.
The only thing that is really "fat" is the apk.

Wil Hadden

unread,
May 1, 2012, 4:13:03 PM5/1/12
to andro...@googlegroups.com
Yeah, sorry for the crappy name, it's something I picked up from my googling research. So do just need to compile a separate so for each CPU and copy it to the usual libs directory and, in my case, Eclipse will do the rest?

Wil Hadden

unread,
May 13, 2012, 6:48:06 PM5/13/12
to andro...@googlegroups.com
Sorry to resurrect this but I am doing something wrong!

I should say that I am using a standalone toolchain so I need to do everything manually. I can create separate so files for every platform I want to support, and obviously I can copy them to libs so they get picked up by the packager. My problem is that when I go to load them with System.loadLibrary I need to supply a specific library name. 

Can anyone tell me what I am doing wrong?

Thanks
Wil 

David Turner

unread,
May 14, 2012, 2:32:47 AM5/14/12
to andro...@googlegroups.com
All libraries should have the same name, but be placed in different ABI-specific directories, as in:

libs/armeabi/libfoo.so
libs/armeabi-v7a/libfoo.so
libs/x86/libfoo.so

The PackageManager will pick up the best library for your device at install time (from the .apk) and copy it to $DATA_DIR/lib/libfoo.so

All you need to do in Java is System.loadLibrary("foo")

For more details on how this works, read $NDK/docs/CPU-ARCH-ABIS.html, it has a section named "CPU ABI Management on the Android platform".

 
Thanks
Wil 

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/UHnv3pSuTzcJ.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Wil Hadden

unread,
May 14, 2012, 4:29:20 AM5/14/12
to andro...@googlegroups.com
Thanks David,

Very concise answer!

Wil

Oyin Oluwatimi

unread,
Jul 20, 2012, 3:08:16 AM7/20/12
to andro...@googlegroups.com
Hey,

Do you use the toolchain to  create custom armeabi-v7a binary? I want to edit/add security based functions to armeabi-v7a. 

Thanks
Damola
Wil

Thanks
Wil 
To unsubscribe from this group, send email to android-ndk+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+unsubscribe@googlegroups.com.

Wil Hadden

unread,
Jul 23, 2012, 5:41:38 AM7/23/12
to andro...@googlegroups.com
I do , the document docs\STANDALONE-TOOLCHAIN.html in the ndk tells you how to use the toolchain.



Wil

To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/7-1W-bvddboJ.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages