FORUMS

Devs Beware – Automatic Backup Privacy Risks

One new feature of “Android M” (speculation on potential names welcomed … more

Android M to Bring New App Drawer

It has now been seen that Android M will receive a new app drawer as part of the stock … more

Which IO Announcement Are You Most Excited About?

The keynote we had all been waiting for has just ended and it’s time to enjoy … more

Google Launches Google Photos At I/O 2015 Keynote

While rumors have been floating around for a while, the Google I/O 2015 has made … more

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

Thanks Meter: 180
 
Post Reply Subscribe to Thread Email Thread
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 06:13 AM. Reason: fix command
The Following 40 Users Say Thank You to tuxboy For This Useful Post: [ View ]
 
 
1st May 2014, 06:56 AM |#3  
Senior Member
Flag Dhaka
Thanks Meter: 272
 
More
Wow. For the tutorial
1st May 2014, 11:40 AM |#4  
Senior Member
Thanks Meter: 373
 
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 12:11 PM.
The Following User Says Thank You to dummie999 For This Useful Post: [ View ]
1st May 2014, 12:12 PM |#5  
tuxboy's Avatar
OP Member
Flag Dhaka
Thanks Meter: 180
 
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, 12:50 PM |#6  
Recognized Contributor
Thanks Meter: 2,804
 
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, 01:10 PM |#7  
migui0401's Avatar
Senior Member
Flag puerto plata
Thanks Meter: 198
 
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, 01:24 PM |#8  
Ricky Divjakovski's Avatar
Recognized Developer / Recognized Contributor
Flag Sydney
Thanks Meter: 5,508
 
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, 02:05 PM |#9  
tuxboy's Avatar
OP Member
Flag Dhaka
Thanks Meter: 180
 
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, 02:52 PM |#10  
jazzespresso's Avatar
Senior Member
Flag NYC, USA
Thanks Meter: 1,016
 
Donate to Me
More
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