We don't bite newbies here... much | |
PerlMonks |
Re: How to get all shared libs of a path?by shmem (Chancellor) |
on Jun 20, 2021 at 20:48 UTC ( [id://11134093]=note: print w/replies, xml ) | Need Help?? |
I'm using Linux env. I'm looking for a way to get all shared libraries of path. First question: why? for what purpose? 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 Section
Seekers of Perl Wisdom
|
|