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

Hi!
I need to call function "a" from function "b" in my XS code. I'v tried something like this:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <stdio.h>


MODULE = MySOTester             PACKAGE = MySOTester


void 
a ()
    CODE:
       printf("Hello\n");



void
b()
    CODE:
        a();
        printf("World!\n");
But it is not works. My program dies with error: /usr/bin/perl: symbol lookup error

How can I resolve this problem?

Replies are listed 'Best First'.
Re: symbol lookup error
by Anonymous Monk on Feb 26, 2009 at 15:10 UTC
    because b() isn't the name of that function, its XS_MySOTester_a. See xsubpp
Re: symbol lookup error
by ikegami (Patriarch) on Feb 26, 2009 at 16:22 UTC

    The purpose of XS is to convert from Perl calling semantics to C ones, convert the returned value to something perlish.

    I don't have much XS experience, but it seems wrong to me to call a glue function from C. You'd do better to put a and b in another file.

    /* my.xs */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "my.h" MODULE = MySOTester PACKAGE = MySOTester void a() void b()
    /* my.h */ extern void a(); extern void b();
    /* my.c */ #include "my.h" #include <stdio.h> void a() { printf("Hello\n"); } void b() { a(); printf("World!\n"); }

    Not tested.