Hello Josef,

Josef Wolf wrote:
Hello,

I have created my XS, and it works as expected when I link everything
statically.

Then I linked dynamically and installed it by "make install".  This
installs following files:

  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/Kdb.so
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/Kdb.bs
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/autosplit.ix
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/.packlist
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/Kdb.a
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/extralibs.ld
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/auto/Kdb/extralibs.all
  /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi/Kdb.pm

When I run the program from the directory where I compiled it, it runs
fine.  But when I try to run it from a different directory, I get this
error message:

  [EMAIL PROTECTED]:~/kdb> (cd /; ~/kdb/test)
  ~/kdb/test: error while loading shared libraries: 
Kdb/blib/arch/auto/Kdb/Kdb.so: cannot open shared object file: No such file or 
directory

Please note the "Kdb/blib/arch" prefix.  This prefix is correct when
the program is run from the compilation directory.  But when the
compilation directory is not available, the library should be searched
in auto/Kdb/Kdb.so since that's where "make install" installed it
(relative to /usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi,
which is in perl's @INC array).

Any ideas what's going on here?


What do you have in the Kdb.pm file and how do you load the module in the test.pl file?

In my .pm file I have the following:


.....
require Exporter;
require DynaLoader;
use AutoLoader;

our @ISA = qw(Exporter DynaLoader);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration       use AFPDS::Info ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
#our %EXPORT_TAGS = ( 'all' => [ qw(
        
#) ] );

#our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

#our @EXPORT = qw(
        
#);
our $VERSION = '0.01';

sub AUTOLOAD {
    # This AUTOLOAD is used to 'autoload' constants from the constant()
    # XS function.  If a constant is not found then control is passed
    # to the AUTOLOAD in AutoLoader.

    my $constname;
   our $AUTOLOAD;
    ($constname = $AUTOLOAD) =~ s/.*:://;
    croak "& not defined" if $constname eq 'constant';
    local $! = 0;
    my $val = constant($constname, @_ ? $_[0] : 0);
    if ($! != 0) {
        if ($! =~ /Invalid/ || $!{EINVAL}) {
            $AutoLoader::AUTOLOAD = $AUTOLOAD;
            goto &AutoLoader::AUTOLOAD;
        }
        else {
            croak "Your vendor has not defined AFPDS::Info macro $constname";
        }
   }
    {
        no strict 'refs';
        # Fixed between 5.005_53 and 5.005_61
        if ($] >= 5.00561) {
            *$AUTOLOAD = sub () { $val };
        }
        else {
            *$AUTOLOAD = sub { $val };
        }
   }
    goto &$AUTOLOAD;
}

Reply via email to