Shared library loading and static constructor

Sobaya sobaya007 at gmail.com
Fri Mar 22 10:51:58 UTC 2019


I fail to load the shared library created in a specific 
situation, but I do not know the cause.

---- a.d
import b.d
----

---- b.d
static this() {}
----

for above 2 files, I created shared library by following command.

dmd a.d -shared -of=a.so

And I ran below code, but the library is not loaded.

--- main.d
void main() {
     import core.runtime;
     auto lib = Runtime.loadLibrary(a.so)
     assert(lib !is null);
}
---

Please tell me why. Thanks.


More information about the Digitalmars-d-learn mailing list