On Tuesday 10 February 2009 06:23:47 Thomas Rowe wrote:
> I'm trying to embed perl in a C++ application and have some perl modules
> call back into the C++.  I cannot figure out how to make the bootstrap
> work on my callback module.  When I eval "use Callback;" I get "Can't
> locate loadable object for module Callback in @INC" even though the
> Callback stuff is linked in.  It shouldn't be looking for a .so file.
> The DynaLoader stuff works fine for other modules.
>
> Here's what I got:
>
> Makefile:
>       OBJS = main.o perlxsi.o callbackxs.o
>       ...
>       main : $(OBJS) # my callbackxs.o should link in here fine, right?
>               $(CC) -o $@ $^ $(PERLLD)
>
>       callbackxs.o : callback.xs
>               xsubpp callback.xs > callbackxs.cpp
>               $(CC) -c callbackxs.cpp $(PERLCXX)  # compiles fine.
>       ...
>
> perlxsi.c:
>       EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
>       EXTERN_C void boot_Callback (pTHX_ CV* cv);
>
>       EXTERN_C void
>       xs_init(pTHX)
>       {
>               char *file = const_cast<char*>( __FILE__ );
>               dXSUB_SYS;
>               newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
>               newXS("Callback::boot_Callback", boot_Callback, file);
>       }
>
> main.cpp:
>       perl_parse(my_perl, xs_init, arg_count, const_cast<char**>(args), 
> NULL); #
> dynaloader works fine
>
> I can see "XS(boot_Callback)" defined just fine in the code spat out by
> xsubpp on my xs file.
>
> What gives?  What's the missing step to tell perl about linked in module
> code?

Have you tried putting something into %INC? See its entry in perldoc perlvar:

http://perldoc.perl.org/perlvar.html

%INC is very useful for mocking modules even in pure-Perl scenarios.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://xrl.us/bjn8s

<mauke>    I'm not interested in what you're doing; what are you trying to 
           achieve?
<PerlJam>  mauke: I'm trying to achieve world peace and this regex is
           the last thing standing in my way! ;)

Reply via email to