Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP tuxboy

1st May 2014, 01:16 AM   |  #1  
tuxboy's Avatar
OP Member
Flag Dhaka
Thanks Meter: 125
 
40 posts
Join Date:Joined: Dec 2013
Donate to Me
More
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!
Last edited by tuxboy; 1st June 2014 at 07:13 AM. Reason: fix command
The Following 37 Users Say Thank You to tuxboy For This Useful Post: [ View ]
1st May 2014, 02:54 AM   |  #2  
OdSazib's Avatar
Member
Flag Dhaka
Thanks Meter: 110
 
76 posts
Join Date:Joined: Oct 2013
Donate to Me
More
Cool
Nice tutorial Thanks a lot
1st May 2014, 07:56 AM   |  #3  
Member
Flag Dhaka
Thanks Meter: 203
 
67 posts
Join Date:Joined: Apr 2013
More
Wow. For the tutorial
1st May 2014, 12:40 PM   |  #4  
Senior Member
Thanks Meter: 353
 
684 posts
Join Date:Joined: Mar 2014
More
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?
Last edited by dummie999; 1st May 2014 at 01:11 PM.
The Following User Says Thank You to dummie999 For This Useful Post: [ View ]
1st May 2014, 01:12 PM   |  #5  
tuxboy's Avatar
OP Member
Flag Dhaka
Thanks Meter: 125
 
40 posts
Join Date:Joined: Dec 2013
Donate to Me
More
Quote:
Originally Posted by dummie999

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: [ View ]
1st May 2014, 01:50 PM   |  #6  
Recognized Contributor
Thanks Meter: 2,514
 
3,546 posts
Join Date:Joined: Oct 2012
More
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: [ View ]
1st May 2014, 02:10 PM   |  #7  
migui0401's Avatar
Senior Member
Flag puerto plata
Thanks Meter: 193
 
227 posts
Join Date:Joined: Jul 2013
More
In there any way to use this in windows?
The Following User Says Thank You to migui0401 For This Useful Post: [ View ]
1st May 2014, 02:24 PM   |  #8  
Ricky Divjakovski's Avatar
Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 5,400
 
3,633 posts
Join Date:Joined: Feb 2013
Donate to Me
More
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

In there any way to use this in windows?

maybe adb shell with busybox installed..
1st May 2014, 03:05 PM   |  #9  
tuxboy's Avatar
OP Member
Flag Dhaka
Thanks Meter: 125
 
40 posts
Join Date:Joined: Dec 2013
Donate to Me
More
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: [ View ]
1st May 2014, 03:52 PM   |  #10  
jazzespresso's Avatar
Senior Member
Flag NYC, USA
Thanks Meter: 777
 
1,436 posts
Join Date:Joined: Jul 2012
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?

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes