Dynamically Loading a D DLL From a C Program in Linux

John McFarlane via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 24 13:59:19 PDT 2014


I'm following the preliminary example "Dynamically Loading a D 
DLL From a C Program" here: http://dlang.org/dll-linux.html#dso9

Firstly, my output is different:

+main()
libdll.so is loaded
dll() function is found
dll()
unloading libdll.so
-main()

If looks like static this and ~this are not being called.

Secondly, when I replace printf with writeln, I get a seg fault. 
Trying to do just about anything beyond adding numbers and 
returning the result causes a similar crash.

I'm wondering whether D runtime is being initialized correctly. 
Can anyone suggest what I would do to ensure this? A more 
finalized example would be useful also.

DMD64 D Compiler v2.066.0
Ubuntu 10.04 64bit

Many thanks,
John


More information about the Digitalmars-d-learn mailing list