I have created a module LicenseInterface.pm built with SWIG. LicenseInterface.so references 2 other shared objects libLicIntfcLib.so and llibmgr11.so which I am including in the auto/LicenseInterface directory.

I cannot get it to load properly for my end application where I am trying to use ActiveState PerlApp to distribute the code as a pre-packaged Linux .exe file (but it works fine in Windows)

use strict; use warnings; push @INC,"lib"; require LicenseInterface; print "LicenseInterface got loaded\n";

Here is the lib directory structure

test.pl |--lib\ |--LicenseInterface.pm |--auto\ |--LicenseInterface\ |--LicenseInterface.bs (added this to try to influence @dl_resolv +e_using) |--LicenseInterface.so |--libLicIntfcLib.so |--llibmgr11.so

Here is the ldd report for the shared objects (without LD_LIBRARY_PATH set)

[boleary@new-host testLib]$ ldd auto/LicenseInterface/LicenseInterface +.so linux-gate.so.1 => (0x00f36000) libLicIntfcLib.so => not found ****This is the .so that dynaload +er can't resolve*** libperl.so => not found ###BUT THIS ONE gets resolved!!! libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00508000) libm.so.6 => /lib/libm.so.6 (0x00331000) libc.so.6 => /lib/libc.so.6 (0x00ac4000) /lib/ld-linux.so.2 (0x002c3000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00ed9000) [boleary@new-host testLib]$ ldd auto/LicenseInterface/libLicIntfcLib.s +o linux-gate.so.1 => (0x0025c000) liblmgr11.so => not found ****This is the other .so that dynaload +er can't resolve*** libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00682000) libm.so.6 => /lib/libm.so.6 (0x00ce7000) libc.so.6 => /lib/libc.so.6 (0x00d40000) /lib/ld-linux.so.2 (0x002c3000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00143000)

When I use or require LicenseInterface.pm, the DynaLoader bootstrap code cannot resolve the libLicIntfcLib.so (and the llibmgr11.so) (I set PERL_DL_DEBUG to 1 before running to get more info)

DynaLoader.pm loaded (/opt/ActivePerl-5.18/site/lib /opt/ActivePerl-5. +18/lib . lib, /lib /usr/lib /usr/local/lib) DynaLoader::bootstrap for LicenseInterface (auto/LicenseInterface/Lice +nseInterface.so) Can't load './auto/LicenseInterface/LicenseInterface.so' for module Li +censeInterface: libLicIntfcLib.so: cannot open shared object file: No + such file or directory at /opt/ActivePerl-5.18/lib/DynaLoader.pm lin +e 191.

I can easily fix the problem if I add the hard path: "auto/LicenseInterface" to the LD_LIBRARY_PATH in the env I am running perl from

export LD_LIBRARY_PATH=./auto/LicenseInterface [boleary@new-host testLib]$ perl test_simple.pl DynaLoader.pm loaded (/opt/ActivePerl-5.18/site/lib /opt/ActivePerl-5. +18/lib . lib, /lib /usr/lib /usr/local/lib ./auto/LicenseInterface) DynaLoader::bootstrap for LicenseInterface (auto/LicenseInterface/Lice +nseInterface.so) LicenseInterface got loaded

The trouble with this is that I am using perlapp from ActiveState to try and build and distribute a working .exe file, and I do not have any control over LD_LIBRARY_PATH in that case (and I know that perlApp is no longer supported)

On a windows system, (where I started this adventure) DynaLoader has no trouble resolving the referenced sharedObjects with LicenseInterface.dll, libLicIntfcLib.dll and llibmgr11.dll and the perlApp .exe file works perectly

I tried a couple of tricks.. Firt I tried to the ./auto/LicenseInterface to the LD_LIBRARY_PATH inside test.pl

BEGIN { $ENV{LD_LIBRARY_PATH}.="./auto/LicenseInterface"; } use strict; use warnings; push @INC,"lib"; require LicenseInterface; print "LicenseInterface got loaded\n"; exit
perl test_simple1.pl DynaLoader.pm loaded (/opt/ActivePerl-5.18/site/lib /opt/ActivePerl-5. +18/lib . lib, /lib /usr/lib /usr/local/lib ./auto/LicenseInterface) DynaLoader::bootstrap for LicenseInterface (auto/LicenseInterface/Lice +nseInterface.so) Can't load './auto/LicenseInterface/LicenseInterface.so' for module Li +censeInterface: libLicIntfcLib.so: cannot open shared object file: No + such file or directory at /opt/ActivePerl-5.18/lib/DynaLoader.pm lin +e 191. at lib/LicenseInterface.pm line 11. Compilation failed in require at test_simple1.pl line 8.

Here you can see that it added ./auto/LicenseInterface to the search path and that status line starting with "DynaLoader.pm loaded (" looks identical to the passing case above, but It still won't load it

Then I tried adding a LicenseInterface.bs file in the ./auto/LicenseInterface directory

push @dl_resolve_using=dl_findfile( qw( ./auto/LicenseInterface/libLicIntfcLib.so ./auto/LicenseInterface/liblmgr11.so ) );
perl test_simple1.pl DynaLoader.pm loaded (/opt/ActivePerl-5.18/site/lib /opt/ActivePerl-5. +18/lib . lib, /lib /usr/lib /usr/local/lib ./auto/LicenseInterface) DynaLoader::bootstrap for LicenseInterface (auto/LicenseInterface/Lice +nseInterface.so) BS: ./auto/LicenseInterface/LicenseInterface.bs (linux, dl_dlopen.xs) dl_findfile(./auto/LicenseInterface/libLicIntfcLib.so ./auto/LicenseIn +terface/liblmgr11.so) dl_findfile found: ./auto/LicenseInterface/libLicIntfcLib.so ./auto/Li +censeInterface/liblmgr11.so Can't load './auto/LicenseInterface/LicenseInterface.so' for module Li +censeInterface: libLicIntfcLib.so: cannot open shared object file: No + such file or directory at /opt/ActivePerl-5.18/lib/DynaLoader.pm lin +e 191. at lib/LicenseInterface.pm line 11. Compilation failed in require at test_simple1.pl line 8.

You can see that it actually found the other shared objects, but it still couldn't use them

It seems that DynaLoader cannot take advantage of the fact that I set LD_LIBRARY_PATH, so when it does its magic it must be limited to using the environment variables from the shell that started it. It is interesting to me that it can resolve the libperl.so

Does anyone have any ideas? Are there any known linux modules that are provided with multiple .so files that have worked around this before?

I can try to create one .so, with the other 2 .so libraries statically linked, but I am having trouble because I don't have total control over the llibmgr11 source.


In reply to DynaLoader can't resolve multiple Linux shared objects by boleary

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.