3

I just purchased a commercial perl shared object that is really light on its documentation. Specifically it's an ".so" file and I know that it needs to go into whatever directory perl is using to find shared objects.

Normally I encounter ".pm" files and know how to install those with no problem, but this is the first time I have ever used something in perl where I had to install a ".so" file, or copy it to a directory.

Anyone know how I would find this directory? It's at a level of Perl's sausage making which I'm not familiar with (plus I'm a bacon gal anyway. LOL!). Janie

Update: (for more clarity). The company that sold this has the file named as "hcmodule.so". Their example perl script has a use pragma in it of "use hcmodule" and a call later as..

$retval = hcmodule( ........ <SNIP>..);

If this helps unmurky things a bit.

Jane Wilkie
  • 1,703
  • 3
  • 25
  • 49
  • 1
    It seems odd paying money for something and then asking the community for support. Surely either the library supplier can tell you how to make it work or they should give you your money back. – Grant McLean Aug 19 '11 at 00:07
  • 1
    Grant, the question is where is the perl shared objects directory found. Quite appropriate for S.O. and not a support question per se regarding the product itself. Thanx. – Jane Wilkie Aug 19 '11 at 14:06

2 Answers2

7

Perl loads shared objects from directories under its lib directory. In some installations of Perl, that will be the lib directory parallel to the bin directory where the main Perl binary is found. In some systems, it will be located elsewhere. For example, my own build of Perl (5.14.1 on MacOS X) says (part of output from perl -V):

@INC
/Users/jleffler/Perl/v5.14.1-64/lib/perl5/site_perl/5.14.1/darwin-2level
/Users/jleffler/Perl/v5.14.1-64/lib/perl5/site_perl/5.14.1
/Users/jleffler/Perl/v5.14.1-64/lib/perl5/5.14.1/darwin-2level
/Users/jleffler/Perl/v5.14.1-64/lib/perl5/5.14.1

On the other hand, the system Perl (5.12.3) says:

@INC:
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
/Network/Library/Perl/5.12/darwin-thread-multi-2level
/Network/Library/Perl/5.12
/Library/Perl/Updates/5.12.3
/System/Library/Perl/5.12/darwin-thread-multi-2level
/System/Library/Perl/5.12
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.12

The shared objects on MacOS X have a .bundle extension (instead of .so), and some of the bundles I have are:

.../lib/perl5/site_perl/5.14.1/darwin-2level/auto/DBD/Informix/Informix.bundle
.../lib/perl5/site_perl/5.14.1/darwin-2level/auto/DBD/SQLite/SQLite.bundle
.../lib/perl5/site_perl/5.14.1/darwin-2level/auto/DBI/DBI.bundle

The corresponding PM files are:

.../lib/perl5/site_perl/5.14.1/darwin-2level/DBD/Informix.pm
.../lib/perl5/site_perl/5.14.1/darwin-2level/DBD/SQLite.pm
.../lib/perl5/site_perl/5.14.1/darwin-2level/DBI.pm

In any case, Perl will expect to look for the .so file in a directory related to the name of the module. There should be install instructions, especially since you paid for it. There will be (at least) a shared object and a .pm file to be installed, in two related related directories.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
4

Have you tried perl -V to see if it has the information you want? Do you have the environment variable LD_LIBRARY_PATH set?

I'm on Linux, and doing perl -V (uppercase V) showed that Perl libraries are in /usr/lib/perl/5.10 and a few other libraries.

Exactly what Perl *.so file did you purchase? I've never heard of someone selling Perl shared libraries.

David W.
  • 105,218
  • 39
  • 216
  • 337
  • 5
    Probably also worth mentioning that the Perl binary API changes between releases, so this `.so` will turn into a pumpkin when you upgrade from Perl 5.10 to Perl 5.12 (for instance). –  Aug 18 '11 at 22:13
  • Thanks David W. It makes perfect sense to sell an .so for perl. It stands to reason that if you're smart enough to install a .pm, you're also smart enough to reverse engineer it. .so as a binary makes reverse engineering a lot more difficult than just using a plain text editor to view the script. It's a very industry specific business I am in (health care) where perl is used quite a bit. It's the .so part that throws me since, like you, I've never had to buy an .so. If their business model works, more power to 'em. I'm not looking to reinvent the wheel and what we spent on this is worth it. – Jane Wilkie Aug 19 '11 at 14:03
  • 1
    So, how is the *.so used? There certainly must be a *.pm module that calls it. In that case, it should be in the `auto` directory that's in the `@INC`. You can run this `perl -e 'print join "\n", @INC;'` and get a list of directories your modules use. Somewhere there, there's an `auto` directory where you deposit the .so. Under the auto, it's probably in the same directory structure as the `.pm` that uses it. Is there a `*.pm` file too? – David W. Aug 19 '11 at 20:42
  • Hi David. Ultimately I discovered that the perl version that was used to compile the .so was 5.8. I used perlbrew to figure that one out (what a NICE option to use when you need to). There's a great link here about it. It's an XS module interface. https://bugs.archlinux.org/task/9078 JW – Jane Wilkie Aug 22 '11 at 16:47