niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » HP-UX
How to list members of a shared library
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Paul Pluzhnikov
*nix forums Guru


Joined: 25 Mar 2005
Posts: 512

PostPosted: Fri Jul 14, 2006 2:31 am    Post subject: Re: How to list members of a shared library Reply with quote

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
Amadeus W. M.
*nix forums addict


Joined: 01 Jul 2005
Posts: 58

PostPosted: Thu Jul 13, 2006 7:23 pm    Post subject: Re: How to list members of a shared library Reply with quote

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
Robert Heller
*nix forums beginner


Joined: 07 Jun 2006
Posts: 2

PostPosted: Thu Jul 13, 2006 5:44 pm    Post subject: Re: How to list members of a shared library Reply with quote

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.

Quote:

Thanks,
Dan McKinley
McKINLDJ@westinghouse.com



--
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
McKinldj@westinghouse.com
*nix forums beginner


Joined: 13 Jul 2006
Posts: 1

PostPosted: Thu Jul 13, 2006 3:58 pm    Post subject: How to list members of a shared library Reply with 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?

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
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Fri Nov 21, 2008 1:09 pm | All times are GMT
navigation Forum index » *nix » HP-UX
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts database Share Memory Limit (2 GB ) in a Instance is tota... sadanjan@gmail.com IBM DB2 0 Fri Jul 21, 2006 12:57 pm
No new posts statistics library Arkadiusz Stasiak C++ 1 Fri Jul 21, 2006 11:40 am
No new posts List History Backup Gladiator IBM DB2 3 Fri Jul 21, 2006 8:21 am
No new posts Testing my Black List Marc Perkel Exim 6 Fri Jul 21, 2006 5:57 am
No new posts Your Opinion about how to set up a DNS list Marc Perkel Exim 0 Fri Jul 21, 2006 2:18 am

Loans | Mortgage Calculator | Loans | RC Boats | Cell Phone
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
[ Time: 0.3605s ][ Queries: 20 (0.2618s) ][ GZIP on - Debug on ]