in reply to Embedding Perl Interpreter/DynaLoader

Personally I use the ExtUtils::Embed option to generate the xs_init() code, and link that into my binary that includes perl functionality.

Parts of my Makefile look like this:

CONFIG_PM=-MConfig PRIVLIB=`$(PERL) $(CONFIG_PM) -e 'print $$Config{privlibexp}'` EXTUTILS_EMBED = $(PERL) -MExtUtils::Embed PERL_CFG_CCFLAGS = `$(PERL) $(CONFIG_PM) -e 'print "$$Config{ccflags} +$$Config{cccdlflags}"'` PERL_CFG_ARCHLIB = `$(PERL) $(CONFIG_PM) -e 'print $$Config{archlibexp +}'` PERL_CCFLAGS = -I$(PERL_CFG_ARCHLIB)/CORE $(PERL_CFG_CCFLAGS) $(PERL_H +OOKS) $(TRACE) STATIC_EXTS=Sybase::OpnSrv XS_INIT = `$(EXTUTILS_EMBED) -e xsinit -- -std $(PERL_STATIC_EXTS) $(S +TATIC_EXTS)` CC=`$(PERL) $(CONFIG_PM) -e 'print $$Config{cc}'` LD=`$(PERL) $(CONFIG_PM) -e 'print "$$Config{ld}\n"'` .... SRC=xp_perl.c perlxsi.c ... # other files OBJS=$(SRC:.c=.o) perlxsi.c: $(XS_INIT)
This generates a perlxsi.c file like this:
#include <EXTERN.h> #include <perl.h> EXTERN_C void xs_init (pTHXo); EXTERN_C void boot_Sybase__OpnSrv (pTHXo_ CV* cv); EXTERN_C void boot_DynaLoader (pTHXo_ CV* cv); EXTERN_C void xs_init(pTHXo) { char *file = __FILE__; dXSUB_SYS; newXS("Sybase::OpnSrv::bootstrap", boot_Sybase__OpnSrv, file); /* DynaLoader is a special case */ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); }
which bootstraps all of the static modules when the perl interpreter is started.

Michael