Module static constructor doesn't work?
kinke
kinke at gmx.net
Thu Aug 8 16:42:40 UTC 2019
On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov wrote:
> But if I create library from lib.d first and then link it with
> main.d then ctor/dtor are not called:
For this to work as expected, the `lib.obj` object file needs to
be linked into the final executable. As main.d doesn't need
anything from lib.d, the linker will skip it by default if it's
in a static library. An `import lib1.lib` isn't enough, you need
to reference some symbol in main.d. Or instruct the linker to use
all object files in the static library (e.g., via /WHOLEARCHIVE
with the MS linker).
More information about the Digitalmars-d-learn
mailing list