in reply to Why does the h2xs -x switch not generate XSUBs?

If I follow
SYNOPSIS h2xs [OPTIONS ...] [headerfile ... [extra_libraries]]
and change order to
h2xs -Oxan TwinTree libtwintree.h -L/usr/local/lib -llibtwintree
I get
Scanning libtwintree.h for functions... 'cppstdin' is not recognized as an internal or external command, operable program or batch file. 'cppstdin' is not recognized as an internal or external command, operable program or batch file.
Your hand makefile scares me :) I thought Makefile.PL make makefile.

Replies are listed 'Best First'.
Re^2: Why does the h2xs -x switch not generate XSUBs?
by FloydATC (Deacon) on Jul 24, 2009 at 11:44 UTC
    See, normally the order doesn't matter but in this case it obviously does. So noted. So I change the order, this time TwinTree.xs shows some improvement although I still can't see any actual XSUB code:
    #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include <libtwintree.h> #include "const-c.inc" MODULE = TwinTree PACKAGE = TwinTree INCLUDE: const-xs.inc int return_one() int return_zero()
    Declarations are a good place to start, but the definitions are still missing. When trying 'make test' on the module, this is what I get:
    PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'bl +ib/arch')" t/*.t t/TwinTree....NOK 1 # Failed test 'use TwinTree;' # at t/TwinTree.t line 9. # Tried to use 'TwinTree'. # Error: Can't load '/home/floyd/twintree/TwinTree/blib/arch/auto +/TwinTree/ TwinTree.so' fo +r module TwinTree: /home/floyd/twintree/TwinTree/blib/arch/auto/T + winTree/TwinTree.so: undefine +d symbol: return_one at /usr/lib/perl5/5.8.8/i386-l + inux-thread-multi/DynaLoader.pm line 230. # at (eval 4) line 2 # Compilation failed in require at (eval 4) line 2. # BEGIN failed--compilation aborted at (eval 4) line 2. # Looks like you failed 1 test of 1. t/TwinTree....dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/TwinTree.t 1 256 1 1 100.00% 1 Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay. make[1]: *** [test_dynamic] Error 1 make[1]: Leaving directory `/home/floyd/twintree/TwinTree' make: *** [TwinTree.pm] Error 2
    By the way, don't be scared by that handmade Makefile, that's for the C project. The h2xs generated Makefile.PL lives in the TwinTree subdirectory.

    -- Time flies when you don't know what you're doing

      although I still can't see any actual XSUB code

      No, what you have there is sufficient.

      ... int return_one() int return_zero()

      What you posted later is overkill.

      ... int return_one() CODE: RETVAL = return_one(); OUTPUT: RETVAL int return_zero() CODE: RETVAL = return_one(); OUTPUT: RETVAL
      Declarations are a good place to start, but the definitions are still missing.

      I'm sorry, what?

      When trying 'make test' on the module, this is what I get

      How did you compile libtwintree? Does it export symbols return_one return_zero? Is libtwintree.so in path? What does ldd /blib/arch/auto/TwinTree/TwinTree.so return?

        All my compile switches are in the Makefile, as are the commands for installing the .so into /usr/local/lib

        As for ldd blib/arch/auto/TwinTree/TwinTree.so it says

        libc.so.6 => /lib/libc.so.6 (0xb7f24000) /lib/ld-linux.so.2 (0x0071d000)

        -- Time flies when you don't know what you're doing