trashkalmar
trashkalmar

Reputation: 883

How to build Android NDK .so without STL?

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?

Upvotes: 2

Views: 689

Answers (2)

Andrey Kamaev
Andrey Kamaev

Reputation: 30132

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?

Upvotes: 1

K-ballo
K-ballo

Reputation: 81379

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?

Upvotes: 0

Related Questions