LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-04-2003, 01:52 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Rep: Reputation: 46
libraries


a long tiem ago I was given a command that would tell me what libraries a binary calls, you ran it in this commandline

$ command binary

that simple it would then print a list of libraries.

does anyone knwo what this command/program is?
 
Old 09-04-2003, 01:56 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
You may be talking about strace:
strace your_command
 
Old 09-04-2003, 01:56 PM   #3
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 45
ldd program
 
Old 09-04-2003, 02:11 PM   #4
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Original Poster
Rep: Reputation: 46
ldd is what I was looking for, now here is the tricky question:
lld lynx gives this:
ldd `which lynx`
libz.so.1 => /usr/lib/libz.so.1 (0x4002a000)
libncurses.so.5 => /lib/libncurses.so.5 (0x40038000)
libssl.so.0 => /usr/lib/libssl.so.0 (0x40074000)
libcrypto.so.0 => /usr/lib/libcrypto.so.0 (0x400a5000)
libc.so.6 => /lib/libc.so.6 (0x401a2000)
libdl.so.2 => /lib/libdl.so.2 (0x402d5000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

what would I do in a shell script to make that output to this:

ldd ${i}
needed command to make that go into a variable like this:
echo ${out}
libz.so.1 libncurses.so.5 libssl.so.0 libcrypto.so.0 libc.so.6 libdl.so.2 linux.so.2

basically I need to get a list of the libraries a program (${i}) needs and have that list in the format of each one next to the other in a variable (${out})

any ideas?
 
Old 09-04-2003, 02:21 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Try this:
echo -n `ldd \`which lynx\`| cut -d"=" -f1 | awk {'print $1'}`
 
Old 09-04-2003, 02:28 PM   #6
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Original Poster
Rep: Reputation: 46
that worked great, now 2 questions

1) when I add this to a script I am working on should I give you credit by saying: "I love it, I got it at Ross?"?

2) how do I cut /lib/ld-linux.so.2 out of the end of the output :-P I am not a newbie, but in the 4 years I have used linux I have never done anything in text/string manipulation.
 
Old 09-04-2003, 02:41 PM   #7
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
1) Completely up to you - I ain't exactly going to prosecute
Clicking the Affero button is a good way to show appreciation and it helps LQ at the same time.
2) If you mean get rid of "/lib/" then you could use sed:
echo `ldd \`which lynx\`| cut -d"=" -f1 | sed {'s/\/lib\///'} | awk {'print $1'}`
 
Old 09-04-2003, 02:45 PM   #8
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Original Poster
Rep: Reputation: 46
I think I will be looking into these, sed, awk, and cut commands/programs
 
Old 09-04-2003, 02:49 PM   #9
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
They all have their uses - once you get used to them then it isn't too hard to see when tou use them. awk and sed can actually get quite complicated and involve large scripts in more complex cases.
 
Old 09-04-2003, 03:10 PM   #10
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Original Poster
Rep: Reputation: 46
well, actually I needed them for a script I am working on, it is a 2000 line *(so far) script that will take a directory of taballs/subdirectories, compile sourcecodes in configure/make perl, python, precompiled, then install or make packages of them using rpm, tgz, deb or a tar.bz2 with a few helpers inside. almost done, just needed this to help top it off.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c libraries kpachopoulos Programming 1 10-19-2005 05:37 PM
libraries sharapchi Slackware 2 03-10-2005 05:40 PM
g++ libraries ofada Programming 1 04-09-2004 11:47 AM
where C/C++ Libraries??? tthai01 Programming 4 01-01-2003 10:31 PM
C/C++ libraries mikeshn Programming 3 07-27-2002 08:41 AM


All times are GMT -5. The time now is 08:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration