teh_steev has asked for the wisdom of the Perl Monks concerning the following question:

This is my first time creating a perl module from C with xs, and I've been stuck for hours with the same problem. (The module is imaginatively titled 'module'.

steve@thelaptop:~/module$ make test PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/postfix....NOK 1 # Failed test (t/module.t at line 10) # Tried to use 'module'. # Error: Can't load '/home/steve/module/blib/arch/auto/module/mod +ule.so' for module postfix: libpfq: cannot open shared object file: N +o such file or directory at /usr/lib/perl/5.8/DynaLoader.pm line 225. # at (eval 4) line 2 # Compilation failed in require at (eval 4) line 2. # BEGIN failed--compilation aborted at t/module.t line 10. t/module....ok 2/2# Looks like you failed 1 test of 2. t/module....dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/2 tests, 50.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/postfix.t 1 256 2 1 50.00% 1 Failed 1/1 test scripts, 0.00% okay. 1/2 subtests failed, 50.00% okay. make: *** [test_dynamic] Error 1

The shared object libraries it's looking for are definitely there, and are seem to be compiled correctly- make works alright and to be honest I'm kind of at a loss as to what might be amiss. Has anyone had this problem before and if so, how is it resolvable?

Replies are listed 'Best First'.
Re: xs problem
by Velaki (Chaplain) on Aug 24, 2006 at 14:14 UTC

    Hmm...it almost looks like a LD_LIBRARY_PATH issue. What does your C module do?

    Also, have you tried testing it with make test_static just to see if it's a path issue?

    Contemplatively,
    -v.

    "Perl. There is no substitute."
      steve@thelaptop:~/module$ make test_static cd ccode && make make[1]: Entering directory `/home/steve/module/ccode' gcc -shared -Wl,-soname,libpfq -Wl,-E -Wl,-rpath,/usr/lib/perl/5.8.7/C +ORE -o libpfq.so.1 socket.o services.o -lc make[1]: Leaving directory `/home/steve/module/ccode' rm -rf blib/arch/auto/module/module.a cp ccode/libpfq blib/arch/auto/module/module.a /usr/bin/ar cr blib/arch/auto/module/module.a module.o && : blib/arch/ +auto/module/module.a /usr/bin/ar: blib/arch/auto/module/module.a: File format not recognize +d make: *** [blib/arch/auto/module/module.a] Error 1

      I've just tried it with a diagnostics enabled as well and it has replied with:

      Compilation failed in require at test.pl line 5 (#1) (F) The module you tried to load failed to load a dynamic extensio +n. This may either mean that you upgraded your version of perl to one that + is incompatible with your old dynamic extensions (which is known to h +appen between major versions of perl), or (more likely) that your dynami +c extension was built against an older version of the library that i +s installed on your system. You may need to rebuild your old dynamic extensions.

      Which library is 'the library'? Do they mean libc or some library in perl itself? There's nothing in perlxs or perlxstut that says I should link against a specific library.

      The C functions operate on mail queues- deferring and deleting messages and so on.

      Oh, and thanks to the people who set me straight (and edited my post) about formatting- I was going to use code tags but I didn't see it in the list of allowed tags. I should always remember to read the next line as well.

Re: xs problem
by gellyfish (Monsignor) on Aug 24, 2006 at 15:21 UTC

    It can't find libpfq - this is a dynamic linking problem with that library rather than a problem with your XS code.

    /J\