How to call a function from a dll created with d ?

kinke noone at nowhere.com
Sun Jul 3 12:54:45 UTC 2022


On Sunday, 3 July 2022 at 08:15:38 UTC, frame wrote:
> Are you sure?

100%, just try yourself.

> You import `testFunc` as normal import, the compiler ignores 
> `pragma(lib)` - that's only for the linker which will ignore it 
> too since the symbol is already in your executable.

Why would the symbol be defined in the executable? `dimedll.d` 
isn't compiled into the executable.

> A static linked function should generate a very small lib-file 
> and yours look too big to me.

The code is using Phobos std.stdio.writeln templates, so the ~20 
KB for both exe and DLL are to be expected and IMO absolutely 
acceptable.

> I don't know about LDC but with DMD I struggle with static 
> linked DLLs because the library generated does not link to the 
> DLL. To get right results, I need to pass the linker flag 
> -`-L=/IMPLIB` (or `-L=/DLL` for 64bit) to generate a lib-file 
> that is really linked to the DLL later.

DMD's DLL support is waaay behind LDC's, especially once stuff 
gets more interesting than trivial examples.


More information about the Digitalmars-d-learn mailing list