in reply to Re^5: [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 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

Replies are listed 'Best First'.
Re^7: [XS on Win32] How to have the extension's dll export its symbols.
by BrowserUk (Patriarch) on Mar 06, 2008 at 02:48 UTC
    Actually, __declspec(dllexport) probably works fine. I had made the mistake of coding it as...

    According to the (MS Docs), either of those is legal syntax. For their compiler at least. But see below.

    But it exports it as XS_Foo_foo - which is not quite what I want.

    That it is adding XS_* suggests to me that it is not a compiler facility as with MSC++, but rather a macro in one of the Perl specific header files somewhere. Perhaps something associated with the following from XSUB.H?

    XSUB.h:# define XS(name) __declspec(dllexport) XSPROTO(name)

    That said, The grep I just did that found that, also turned up the following tantalising snippet:

    win32\win32.h:/* now even GCC supports __declspec() */

    The grep also turned up a bunch of other __declspec references in 5.10.0 header files. I haven't pursued any of them.

    Seems like it is mostly there but not quite. Maybe what's needed is a Perl specific extended-decl-modifier-seq to add the XS decorations: say XSdllexport so as not to conflict with the 'standard' dllexport.


    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.