Re: How to list members of a shared library - HP UX

This is a discussion on Re: How to list members of a shared library - HP UX ; At 13 Jul 2006 08:58:22 -0700 McKinldj@westinghouse.com wrote: > > 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: How to list members of a shared library

  1. Re: How to list members of a shared library

    At 13 Jul 2006 08:58:22 -0700 McKinldj@westinghouse.com wrote:

    >
    > 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.

    >
    > 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.

    >
    > 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


  2. Re: How to list members of a shared library

    Robert Heller writes:

    >> 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.

    > 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.

+ Reply to Thread