Reduce Binary Size

625 views
Skip to first unread message

laurent mallet

unread,
Aug 23, 2010, 6:08:06 AM8/23/10
to android-ndk
Hello,

I have 3 libraries in my project. The release size is about 5Mo with
default parameters in Android.mk.
After ndk-build, i use "arm-eabi-strip -s libs/armeabi" to reduce size
to 4Mo.
It is too big. So after some googling, i try some interesting flags:

LOCAL_CFLAGS := -ffunction-sections -fdata-sections ...
LOCAL_LDFLAGS := -Wl,-Map=moblox.map,--cref,--gc-section

With these flags, the size is 3Mo. It is working on Nexus One and G1.
But i'm not sure
that these flags are legal. Is there any recommandations for
authorized flags for NDK build ?


Thx,

Anders Hasselqvist

unread,
Aug 23, 2010, 10:47:32 PM8/23/10
to andro...@googlegroups.com
Hi,

Are you using c++?

Maybe -fvisibility=hidden can help.
http://gcc.gnu.org/wiki/Visibility

Thanks,
Anders

> --
> 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...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

laurent mallet

unread,
Aug 24, 2010, 5:39:00 PM8/24/10
to android-ndk
Hi,

You're my savior. The size of my library is now 1.5Mo with all these
flags. It is a bit painfull, but it rocks.

Thanks.

Tiga Liang

unread,
Aug 25, 2014, 12:14:03 AM8/25/14
to andro...@googlegroups.com
Hi:
This post may help.
http://blog.algolia.com/android-ndk-how-to-reduce-libs-size/

在 2010年8月23日星期一UTC+8下午6时08分06秒,laurent mallet写道:
Reply all
Reply to author
Forward
0 new messages