Creating DLL

Ali Çehreli acehreli at yahoo.com
Thu Jun 16 16:19:22 UTC 2022


On 6/16/22 09:07, Sergeant wrote:

 > May I ask one more question: why a code like this would work in
 > D-application but not in D-DLL?

D programs generated by D compilers automatically initialize the D 
runtime. You can do the same with rt_init:

pragma (crt_constructor)
extern(C) int initialize() { // Can have any name
   return rt_init();
}

And to deinitialize;

pragma (crt_destructor)
extern(C) int terminate() { // Can have any name
   return rt_term();
}

Although, I haven't tested it with a DLL but with .so libraries on 
Linux... :/

This answer may be relevant:

   https://forum.dlang.org/post/t8diks$2l79$1@digitalmars.com

Ali



More information about the Digitalmars-d-learn mailing list