Win32 DLLs in D

Andre Pany andre at s-e-a-p.de
Fri Jun 5 22:05:49 UTC 2020


On Friday, 5 June 2020 at 18:00:40 UTC, Poyeyo wrote:
> Hello everyone.
>
> I want to create a windows plugin.dll that could be called from 
> rFactor, and I want to try D first, instead of going directly 
> to C++ as the rFactor example.
>
> I am trying to wrap my head around this:
>
> https://wiki.dlang.org/Win32_DLLs_in_D
>
> ... which seems quite outdated,
>
> and this:
>
> https://forum.dlang.org/post/mscgsclxwtjcferfxoet@forum.dlang.org
>
> ... which seems incomplete,
>
> ... and dub, which makes a mess of all my efforts.
>
> Can someone with the right knowledge please update the wiki 
> with a modern example that also uses dub for both the Dll and 
> the test program?
>
> Dub is not a requirement, just a convenience that would be much 
> appreciated.
>
> Best regards.

Hi,

Create a new dub package with dub init and afterwards change the 
filename app.d to lib.d. Use as file content

``` d
import core.sys.windows.dll;
mixin SimpleDllMain

extern(C) void sample() nothrow
{
}
```

In dub.json set targetType to "dynamicLibrary".

Build with `dub build`

(Written from my mobile, with the knowledge, as far as I 
remember).

Kind regards
Andre


More information about the Digitalmars-d-learn mailing list