|
|
|
|
|
|
| Author |
Message |
McKinldj@westinghouse.com *nix forums beginner
Joined: 13 Jul 2006
Posts: 1
|
Posted: Thu Jul 13, 2006 3:58 pm Post subject:
How to list members of a shared library
|
|
|
I have a file with extension .sl on HP-UX and extension .so on Linux.
How do I list the members of a shared library?
Are shared libraries needed at compile time, run time, or both?
Using the ld command to create the shared libraries, I use -b on HP-UX
and -shared on Linux. Is this correct, or do I need something more?
Thanks,
Dan McKinley
McKINLDJ@westinghouse.com |
|
| Back to top |
|
 |
Robert Heller *nix forums beginner
Joined: 07 Jun 2006
Posts: 2
|
Posted: Thu Jul 13, 2006 5:44 pm Post subject:
Re: How to list members of a shared library
|
|
|
At 13 Jul 2006 08:58:22 -0700 McKinldj@westinghouse.com wrote:
| Quote: |
I have a file with extension .sl on HP-UX and extension .so on Linux.
How do I list the members of a shared library?
|
You don't. A shared library is not like an ar (.a) library. It is
'linked' into a single slab of code. Individual modules are not loaded.
The whole thing gets mapped to shared memory when referenced the first
time and then new references map the *same* memory into their address
space. You *can* use nm to get a list of modules.
| Quote: |
Are shared libraries needed at compile time, run time, or both?
Using the ld command to create the shared libraries, I use -b on HP-UX
and -shared on Linux. Is this correct, or do I need something more?
|
No that is correct. You *should* also use -fPIC -DPIC compile flags
when you compile (gcc/g++). Caution: when using C++ be careful when
using static instances of objects in a shared library.
--
Robert Heller -- 978-544-6933
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller@deepsoft.com -- Contract Programming: C/C++, Tcl/Tk |
|
| Back to top |
|
 |
Amadeus W. M. *nix forums addict
Joined: 01 Jul 2005
Posts: 58
|
Posted: Thu Jul 13, 2006 7:23 pm Post subject:
Re: How to list members of a shared library
|
|
|
On Thu, 13 Jul 2006 08:58:22 -0700, McKinldj wrote:
| Quote: | I have a file with extension .sl on HP-UX and extension .so on Linux.
How do I list the members of a shared library?
|
nm -o libfoobar.so
| Quote: | Are shared libraries needed at compile time, run time, or both?
|
both
| Quote: | Using the ld command to create the shared libraries, I use -b on HP-UX
and -shared on Linux. Is this correct, or do I need something more?
|
This is how I create a shared library in Linux (in a makefile, but with
the obvious changes you can run it at the prompt):
libfoobar.so: $(OBJECTS)
g++ -shared -W1,soname,$@ -o $@ $^
($@ stands for the target libfoobar.so and $^ expands to the dependencies
following the target).
Because it's a shared library, the linker must be told about it, so you
must run (as root):
/sbin/ldconfig /path/to/lib/ # containing libfoobar.so
All this is in linux, with gnu make, etc. |
|
| Back to top |
|
 |
Paul Pluzhnikov *nix forums Guru
Joined: 25 Mar 2005
Posts: 512
|
Posted: Fri Jul 14, 2006 2:31 am Post subject:
Re: How to list members of a shared library
|
|
|
Robert Heller <heller@deepsoft.com> writes:
| Quote: | Using the ld command to create the shared libraries, I use -b on HP-UX
and -shared on Linux. Is this correct, or do I need something more?
No that is correct.
|
Not really.
The correct way to build a shared library is 'gcc -shared' and
'cc -b'.
Unfortunately, older versions of HP 'cc' do not understand the '-b'
flag, and so on HP-UX you have to use 'ld' directly (if your 'cc'
is old).
On all other platforms, linking any user-level code directly with
'ld' is almost always a mistake.
| Quote: | You *should* also use -fPIC -DPIC compile flags
when you compile (gcc/g++).
|
And when you *link* as well.
On some platforms, 'g++' will generate and complie stub code at
link time.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sun Nov 23, 2008 11:46 am | All times are GMT
|
|
Loans | Mortgages | Personal Car Finance | Loans | Online Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|