Is /system/lib/libc++.so Standard Now?

451 views
Skip to first unread message

alex.s...@lookout.com

unread,
Apr 28, 2016, 10:14:55 AM4/28/16
to android-ndk
I'm developing some c++ code and am using libc++_shared.so provided
with the ndk.

However, a spot check on my android L devices shows that there is an
equivalent /system/lib/libc++.so available on all of them:
nexus 5 w/ android L - yes
lg nexus 5x w/ android M - yes
moto x pure w/ android M - yes
samsung galaxy note 5 w/ android M - yes
sony xperia w/ android L - yes
samsung galaxy s4 w/ android 5.0.1 - yes
htc one m8 w/ android M - yes
huawei nexus 6p w/ android M - yes

I'd like to know whether android is now supporting libc++.so as part
of the system libraries.

This is important because packaging libc++_shared.so with my apk
increases its size by 1.2mb!  It would be great to remove this .so
from my apk.

David Turner

unread,
Apr 28, 2016, 11:56:15 AM4/28/16
to andro...@googlegroups.com
Short answer: no

Longer answer: By definition, anything that is not provided by the official NDK system headers is not "standard".

At the moment, this includes /system/lib/libc++.so, which may or may not provide the same binary interface as libc++_shared.so, depending on the device and toolchains being used.


--
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 post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/652660cc-0461-45a1-992e-8dc028b14fac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Albert

unread,
Apr 28, 2016, 12:53:17 PM4/28/16
to android-ndk
If you do that your app will not load on N and newer platforms: http://developer.android.com/preview/behavior-changes.html#ndk

Also, like digit said, it's not standard. libc++.so might be on all those devices, but there's no guarantee that it works, or that it works the same way, or that it's on every device. It also isn't there before L, so you'd be limiting your user base pretty significantly.

Alex Cohn

unread,
Jun 20, 2017, 3:19:26 PM6/20/17
to android-ndk
The question is, won't this /system/lib/libc++.so interfere with native code that relies on STL? I am afraid we are currently investigating such case.

BR,
Alex Cohn

Dan Albert

unread,
Jun 20, 2017, 3:51:00 PM6/20/17
to android-ndk
Not for any NDK newer than r11. The reason for the NDK libc++ ABI break in r11 was to change the namespace from std::__1 to std::__ndk1 to make sure that the two standard libraries were actually distinct. There are a few things that are directly in std (looks like just typeinfo and the standard exceptions types), but since those are entirely contained in the libc++ headers your app should be getting the right definition of them.

To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.

Alex Cohn

unread,
Jun 21, 2017, 7:08:54 AM6/21/17
to android-ndk
Thanks
Reply all
Reply to author
Forward
0 new messages