in reply to Re^2: [XS on Win32] How to have the extension's dll export its symbols.
in thread [XS on Win32] How to have the extension's dll export its symbols.

I'm using the MinGW compiler ...

If you follow the link I belatedly added to my response you'll see that dllexport is an MS specific extension. Presumably the __declspec() bit is a part of some standard otherwise you'd be getting an error.

Whether MinGW supports a similar extension I don't know. They can build .sos an .dlls so must have encountered similar problems.

  1. How does one influence the contents of the def file that is created by that automated procedure ?

    I looked that up a while ago. There is mention in the pod for E::MM of a coniguration attribute DL_FUNCS which seems to be something to do with it.

  2. I changed Foo.xs so that it now has:

    See above:)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^4: [XS on Win32] How to have the extension's dll export its symbols.
by syphilis (Archbishop) on Mar 05, 2008 at 13:35 UTC
    There is mention in the pod for E::MM of a coniguration attribute DL_FUNCS which seems to be something to do with it

    Yes - that's probberly the way to go. I tried inserting 'DL_FUNCS' => {'Foo' => ['boot_Foo', 'foo']}, into WriteMakefile() of the Makefile.PL. Having done that, dumpbin reports that Foo.dll exports XS_Foo_foo, _XS_Foo_foo, boot_Foo and _boot_Foo. I'm wanting to see that foo, _foo, boot_Foo, and _boot_Foo are exported. (I've just got to work out how to remove that "XS_Foo_" prefix.)

    Cheers,
    Rob

      Take a look at ExtUtils::Mksymlists and it's FUNCLIST argument and associated discussion. It provides for adding exports unadorned by the BOOT_ stuff. Note: I've never tried to use it. I just followed the link from the earlier page.

      I'm kinda surprised that MinGW et al haven't added an specific extension to deal with this. Maintain export definitions by hand is a bloody nightmare. (Thought easier than with executable Config files :)


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I had taken a look at the ExtUtils::Mksymlists documentation, but didn't look at anything other than the DL_FUNCS docs. A bit further down, one finds FUNCLIST which seems to do exactly as I've asked. (It turns out that FUNCLIST is also documented in the ExtUtils::MakeMaker documentation.) The appropriate Makefile.PL looks like:
        use ExtUtils::MakeMaker; my %options = %{ { 'TYPEMAPS' => [ 'C:\\perl510_M\\5.10.0\\lib\\ExtUtils\\typemap' ], 'NAME' => 'Foo', 'INC' => '-IC:/temp/Foo_build', 'FUNCLIST' => ['boot_Foo', 'foo'], 'VERSION' => '0.01' } }; WriteMakefile(%options); # Remove the Makefile dependency. Causes problems on a few systems. sub MY::makefile { '' }
        Foo.dll then exports _boot_Foo, _foo, boot_Foo and _foo ... which is exactly what I'm after.

        I'm kinda surprised that MinGW et al haven't added an specific extension to deal with this

        Actually, __declspec(dllexport) probably works fine. I had made the mistake of coding it as
        int __declspec(dllexport) foo(int x, int y)
        whereas I think I needed to code it as
        __declspec(dllexport) int foo(int x, int y)
        Certainly the latter rendition creates a dll that exports foo(). But it exports it as XS_Foo_foo - which is not quite what I want.

        Thanks muchly for the excellent help, BrowserUk.

        Cheers,
        Rob