Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

makemaker and building multiple DLLs

by patcat88 (Deacon)
on May 17, 2011 at 18:49 UTC ( #905340=perlquestion: print w/replies, xml ) Need Help??
patcat88 has asked for the wisdom of the Perl Monks concerning the following question:

Is there any way to get makemaker to make 2 separate XS or 1 XS and 1 pure C DLLs on Windows?

I am trying to code a which will compile not only the XS DLL, but a pure C DLL which is dynamically loaded and unloaded (LoadLibrary/FreeLibrary) by the XS DLL.

I tried using the XS key  XS                 =>  {'ModuleName.xs' => 'ModuleName.c', 'ModuleNameCLib.xs' => 'ModuleNameCLib.c'}, in hash that goes to WriteMakefile, but the final makefile never mentions ModuleNameCLib, only ModuleName.

Edit, reading through the final makefile, it seems impossible for more than 1 DLL to be built. It seems to me, that the only thing I can do, is to put in my own target and hook it on INST_DYNAMIC_DEP, or overload the subdirs target. Copying of PMs are unlimited though, unlike XS or C parts of the perl module.

2nd edit, I figured this is the way to build another non-xs DLL with makemaker, works for me on windows with VS. Its added to the module ISN'T named 2ndlib BTW. We actually compiled 2ndlib.xs, not 2ndlib.c, but 2ndlib.xs is NOT an XS file, xsubpp will complain with

Didn't find a 'MODULE ... PACKAGE ... PREFIX' line

but it can be safely ignored I guess. I put the non-XS dll in a libs folder under the module's auto folder, to prevent dynaloader from trying to accidentally run the DLL, not sure what would happen if it was in the module's auto folder, 2ndlib.dll doesn't export a boot function. 2ndlib.dll isnt a real library, its just for this code sample.
package MY; sub postamble { return <<'ENDTOKEN'; dynamic:: $(INST_ARCHAUTODIR)\libs\2ndlib.dll $(INST_ARCHAUTODIR)\libs\2ndlib.dll : 2ndlib.obj $(LD) -out:$@ $(LDDLFLAGS) 2ndlib.obj $(OTHERLDFLAGS) $(MYEXTLIB) +$(PERL_ARCHIVE) $(LDLOADLIBS) -def:2ndlib.def $(INST_ARCHAUTODIR)\libs\.exists : Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)\libs $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR)\libs $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)\libs\.exists blibdirs : $(INST_ARCHAUTODIR)\libs\.exists ENDTOKEN }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://905340]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2018-02-22 07:26 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.