Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,809,537 Members 37,626 Now Online
XDA Developers Android and Mobile Development Forum

[TUTORIAL] Find out which shared libs (.so) are missing

Tip us?
 
tuxboy
Old
(Last edited by tuxboy; 1st June 2014 at 06:13 AM.) Reason: fix command
#1  
tuxboy's Avatar
Member - OP
Thanks Meter 118
Posts: 40
Join Date: Dec 2013
Location: Dhaka

 
DONATE TO ME
Default [TUTORIAL] Find out which shared libs (.so) are missing

While porting features or ROMs from one Android device to another, some of us frequently encounter missing shared libs error. The process of finding missing shared libraries (.so files) might be a bit trivial, and time consuming. This tutorial is going to demonstrate a one-command way of finding all the dependencies of an executable, or another shared library.

FIRST TIME CONFIGURATION
Open up your terminal, type in:
Code:
$ echo 'readelf -d $1 | grep "\(NEEDED\)" | sed -r "s/.*\[(.*)\]/\1/"' | sudo tee -a /usr/local/bin/ldd-arm
$ sudo chmod +x /usr/local/bin/ldd-arm
[Member @_that told about this (better) way of performing this, without NDK and a more readable output. Thanks!]

FINDING MISSING LIBS

Basic usage is very easy. In your terminal:

Quote:
$ ldd-arm PATH_TO_YOUR_EXECUTABLE_OR_LIBRARY
Say, for example, we want to find out the dependecies (which shared libraries are required) of my sensor HAL. I would type in terminal,

Code:
$ ldd-arm sensors.msm7x27a.so
And, I get the desired output!

Code:
liblog.so
libutils.so
libcutils.so
libhardware.so
libdl.so
libmemalloc.so
libc.so
libstdc++.so
libm.so
And that's how you can find out the libraries you are missing!
The Following 37 Users Say Thank You to tuxboy For This Useful Post: [ Click to Expand ]
 
OdSazib
Old
#2  
OdSazib's Avatar
Member
Thanks Meter 101
Posts: 73
Join Date: Oct 2013
Location: Dhaka

 
DONATE TO ME
Nice tutorial Thanks a lot
Current Device: Walton Primo S2
SOC: Qualcomm Sanpdragon 400 MSM8228
Root Access: Yes
***********************************************
Press on my post if you find valuable

Some of My Recent Works
 
dummie999
Old
(Last edited by dummie999; 1st May 2014 at 12:11 PM.)
#4  
Senior Member
Thanks Meter 300
Posts: 537
Join Date: Mar 2014
Awesome tutorial! But are you sure
Code:
echo 'export PATH=$PATH:LOCATION_OF_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin' > ~/.bashrc
shouldn't be
Code:
echo 'export PATH=$PATH:LOCATION_OF_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin' >> ~/.bashrc
with >> instead of >? You don't want to override your complete ~/.bashrc, right?
HTC Desire 500 One sim
Dropbox: https://db.tt/yxozELzF Signing up will give me some extra space
The Following User Says Thank You to dummie999 For This Useful Post: [ Click to Expand ]
 
tuxboy
Old
#5  
tuxboy's Avatar
Member - OP
Thanks Meter 118
Posts: 40
Join Date: Dec 2013
Location: Dhaka

 
DONATE TO ME
Quote:
Originally Posted by dummie999 View Post
Awesome tutorial! But are you sure echo
Code:
'export PATH=$PATH:LOCATION_OF_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin' > ~/.bashrc
shouldn't be
Code:
echo 'export PATH=$PATH:LOCATION_OF_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin' >> ~/.bashrc
with >> instead of >? You don't want to override your complete ~/.bashrc, right?
I just noticed the typo, thanks for pointing it out. Post updated.

Regards
The Following 2 Users Say Thank You to tuxboy For This Useful Post: [ Click to Expand ]
 
_that
Old
#6  
Recognized Contributor
Thanks Meter 2,425
Posts: 3,428
Join Date: Oct 2012
In my experience, the native (amd64) readelf worked just as well with ARM binaries. I'm using this command line in my script:

Code:
readelf -d $1 | grep '\(NEEDED\)' | sed -r 's/.*\[(.*)\]/\1/'
The final sed leaves only the bare library names in the output.
The Following 3 Users Say Thank You to _that For This Useful Post: [ Click to Expand ]
 
migui0401
Old
#7  
migui0401's Avatar
Senior Member
Thanks Meter 187
Posts: 209
Join Date: Jul 2013
Location: puerto plata
In there any way to use this in windows?
We live android, we breath in android, we love android, we delvelop android, WE ARE ANDROID!
The Following User Says Thank You to migui0401 For This Useful Post: [ Click to Expand ]
 
Ricky Divjakovski
Old
#8  
Ricky Divjakovski's Avatar
Recognized Contributor
Thanks Meter 5,282
Posts: 3,592
Join Date: Feb 2013
Location: Sydney

 
DONATE TO ME
LEGEND!
just the sort of thing i was looking for!
you should just make binary for this, the "lib dependancy viewer"
it should be called by something like
libdepv PATH/TO/LIB

---------- Post added at 10:24 PM ---------- Previous post was at 10:20 PM ----------

Quote:
Originally Posted by migui0401 View Post
In there any way to use this in windows?
maybe adb shell with busybox installed..
Like my blog on facebook, add me to your circles, follow me on twitter or donate to me with paypal
 
tuxboy
Old
#9  
tuxboy's Avatar
Member - OP
Thanks Meter 118
Posts: 40
Join Date: Dec 2013
Location: Dhaka

 
DONATE TO ME
Thanks @_that! Post updated

Sent from my Walton Primo H1 using XDA Free mobile app
The Following 2 Users Say Thank You to tuxboy For This Useful Post: [ Click to Expand ]
 
jazzespresso
Old
#10  
jazzespresso's Avatar
Senior Member
Thanks Meter 660
Posts: 1,263
Join Date: Jul 2012
Location: NYC, USA
good one indeed....ok now say how we can find for ported app's missing or shared libs and its dependency? is this also work?
"Chaos is order yet undeciphered"

================================================== ================
  • Nexus 7 WiFi (2012) - [KK 4.4.4 KTU84P] ♦ [CM11 M9]
  • Galaxy Note 3 - AT&T, Stock ROM 4.4.2
  • Galaxy Tab 2 7 - GT-P3113 - 4.4.4 - Official SlimKat ROM
  • Galaxy Note 8.0 - GT-N5110 - 4.4.2 CivZ-FLEXNOTE-8.0_Rev1.8 with SPen Air Feature
  • HP TouchPad - WebOS - still one of the best OS!
================================================== ================

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes