Why is ndk designed to include libc ++ shared.so

1,266 views
Skip to first unread message

py z

unread,
Apr 22, 2020, 1:24:56 AM4/22/20
to android-ndk
I'm developing some c++ code and am using libc++_shared.so provided with the ndk. my apk
increases its size by 1mb.
I am curious why not use /system/lib/libc++.so? Why not design like liblog and libdl?

Thanks!

Dan Albert

unread,
Apr 22, 2020, 5:36:26 AM4/22/20
to android-ndk
Because there is no stable C++ ABI. You'd have to compile your app for every version of Android individually to ensure compatibility

Beyond that, you'd be stuck with the capabilities of the device you ran on rather than what toolchain you used. For pre-Lollipop you'd be stuck with C++98 stlport, wouldn't get C++14 until Marshmallowish, wouldn't have C++20 until next year's release, etc.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/90162e85-cf21-49ba-96f8-99c8c6ba7d8e%40googlegroups.com.

py z

unread,
Apr 22, 2020, 10:50:41 AM4/22/20
to android-ndk

So for liblog.so, libc.so, libdl.so, why these so are not included in the apk like libc ++ _ shared.so, but under / system / lib。

Thank you very much for your reply.

在 2020年4月22日星期三 UTC+8下午5:36:26,Dan Albert写道:
Because there is no stable C++ ABI. You'd have to compile your app for every version of Android individually to ensure compatibility

Beyond that, you'd be stuck with the capabilities of the device you ran on rather than what toolchain you used. For pre-Lollipop you'd be stuck with C++98 stlport, wouldn't get C++14 until Marshmallowish, wouldn't have C++20 until next year's release, etc.

On Tue, Apr 21, 2020, 22:24 py z <6467...@qq.com> wrote:
I'm developing some c++ code and am using libc++_shared.so provided with the ndk. my apk
increases its size by 1mb.
I am curious why not use /system/lib/libc++.so? Why not design like liblog and libdl?

Thanks!

--
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 andro...@googlegroups.com.

Dan Albert

unread,
Apr 22, 2020, 2:28:03 PM4/22/20
to android-ndk
They're C ABIs so they're stable. They also generally provide functionality that _must_ be provided by the system and can't be bundled in the APK.

To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/c8682bd2-cffd-4271-98ba-a28c20585b18%40googlegroups.com.

py z

unread,
Apr 23, 2020, 6:18:32 PM4/23/20
to android-ndk
Thank you very much for your reply, I have gained a lot, thank you!


在 2020年4月23日星期四 UTC+8上午2:28:03,Dan Albert写道:

李文坤

unread,
Apr 4, 2023, 12:08:54 PM4/4/23
to android-ndk
I heard that ART was written in C ++, so it will load libc++_shared.so for itself when running.  Will it cause conflicts when it loads the libc++_shared.so bundled in the APK ?

enh

unread,
Apr 4, 2023, 1:13:55 PM4/4/23
to andro...@googlegroups.com
no, behind the scenes, the platform libc++ actually has everything in the std::__1:: namespace whereas the ndk libc++ uses std::__ndk::. you can see the different mangled names with objdump or whatever.

Reply all
Reply to author
Forward
0 new messages