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 16:31:21 PDT 2014


On Friday, 24 October 2014 at 22:33:09 UTC, bachmeier wrote:
> I can't answer the first question, but for the second, I've 
> given an example here:
>
> http://forum.dlang.org/post/zfdvrwvgavykauczbreq@forum.dlang.org
>
> I've done that many, many times and do not see any problems 
> related to the runtime.
>
> On Friday, 24 October 2014 at 20:59:20 UTC, John McFarlane 
> wrote:
>> 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

Thanks. That gets me a lot futher.


More information about the Digitalmars-d-learn mailing list