I'm using the newest Android NDK r6b to build my shared object. This library does not use any kind of STL at all, but resulting .so includes many STL stuff like std::bad_alloc_what(void) and many more, which increases size of binary greatly. Also release builds include this garbage. APP_STL not defined anywhere, also the NDK r5b produces small binary with used functions only. Is it a bug of r6b? How can I build with r6b without STL stuff?
Asked
Active
Viewed 680 times
2
-
It's not a bug but we have to live with the fact: http://code.google.com/p/android/issues/detail?id=19881 – Eric Chen Nov 08 '11 at 07:20
2 Answers
1
It seems that there is a bug in NDK r6b and it always builds libraries with exceptions support, even if -fno-exceptions
is explicitly specified.
See this question for details: Android NDK produce unreasonable big binaries, how to optimize .so size?

Community
- 1
- 1

Andrey Kamaev
- 29,582
- 6
- 94
- 88
-
I guess, you're right. It seems, that I should continue using an `old' r5 NDK. Спасибо. – trashkalmar Sep 24 '11 at 20:41
0
If you are using, say, new
then you are implicitly using the standard library for the std::bad_alloc
exception. Unless you call the no-throw version of new
, which would instead use std::nothrow
. If you don't use the standard library, then it won't get linked. Just make sure you don't, if that's what you want, or perhaps just move to C?

K-ballo
- 80,396
- 20
- 159
- 169
-
I'm sure I do not use STL anywhere, because as I've said, r5b builds the library without any STL reference. – trashkalmar Sep 24 '11 at 20:03
-
@trashkalmar: So you don't even use `new` directly or indirectly in the entire code? Any chance r6b is building with exceptions enabled and r5b wasn't? – K-ballo Sep 24 '11 at 20:17
-
Of course, I'm using the `new` many times. How can I figure out whether the r6b turns exceptions on? And how to disable them explicitely? As far as I know, the Android runtime does not support exceptions in C++ code. – trashkalmar Sep 24 '11 at 20:24
-
Well, `std::bad_alloc` is the exception `new` throws when is out of memory. Check for a '--no-exceptions' flag or similar. – K-ballo Sep 24 '11 at 20:28
-
Nothing changed. I assume its a bug in r6b. Anyway, thank you for answer. – trashkalmar Sep 24 '11 at 20:44