I'm using Linux env. I'm looking for a way to get all shared libraries of path.

First question: why? for what purpose?
Second question: in what context? do you mean system context, or your own?

In my insane $HOME I not only have a ~/bin directory with strange things, setting LD_LIBRARY_PATH and LD_PRELOAD but also other funny places where libs are stuffed away, e.g. perlbrew things and custom XS perl packages which sport their own *.so files.

I would go the other way round. The linker already knows where to look for shared libraries. That's in /ec/ld.so.conf and /etc/ld.so.conf.d/*. I'd read these files, get the shared libraries living in these directories (excluding symlinks of course). These are the libs you probably want, for the system. For my own lumber-room I'd include my LD_LIBRARY_PATH values in the directory list.

To get any shared libraries I'd use locate, e.g. locate .so | perl -lnE 'next if -l or !/\.so$/;say' which gets them all.

Depending on what you want to do, you could ask the package manager about the owning package of each lib, using dpkg -S $lib or rpm -qf $lib. Having those packages, you can do a "reverse depends" for these packages and query the resulting packages for binaries in $PATH.

I'm just guessing that you want to do some sort of an inventory, in the posted code you are just getting usage count for each lib. There are other reasons to look up libs, e.g. identify suspicious libs which don't pertain to any package. Hence the first question above.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re: How to get all shared libs of a path? by shmem
in thread How to get all shared libs of a path? by ovedpo15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.