www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D Dll's usefulness

reply Igor <Vladamir.I google.com> writes:
Can D Dll's be linked and used as if they were compiled directly 
with the program? I was thinking of writing some library routines 
and put them in a Dll but now I'm not thinking that would be very 
useful because the Dll's won't export class like behavior.

in my DLL:

class MyClass { void foo() { } }

in my app:

auto c = new MyClass();

I'd like to use MyClass as if it were defined directly here, but 
I think I can only load the dll and attach to foo? Is this right?

Since I'm the "owner" of the library I can always just "drag and 
drop" the source code into the project to get the desired 
behavior. I'd like the DLL to provide that to future projects 
that may not have the source code. Either the DLL's don't support 
this, which I think is the case, or I have to include a "header".

Hopefully there is a tool that could take a "library" that will 
be used as a dll and strip it down into modules that can be 
included into the main app so it can be used as if the source 
code was directly compiled in.

Am I off target here?
Jan 25
next sibling parent reply Kagamin <spam here.lot> writes:
Um... A closed-source library is one thing, DLL is another thing, 
DLL class library is a third thing, seamless linking of DLL class 
library is a fourth thing. Well... see what you can get working.
Jan 25
parent Igor <Vladamir.I google.com> writes:
On Monday, 25 January 2016 at 21:42:07 UTC, Kagamin wrote:
 Um... A closed-source library is one thing, DLL is another 
 thing, DLL class library is a third thing, seamless linking of 
 DLL class library is a fourth thing. Well... see what you can 
 get working.
Thanks for the help! I really appreciate your wisdom and hospitality! Give me your address and I'll send you a thank you card!
Jan 25
prev sibling parent Benjamin Thaut <code benjamin-thaut.de> writes:
On Monday, 25 January 2016 at 19:45:21 UTC, Igor wrote:
 Am I off target here?
Dlls are currently not properly supported in D, I would strongly advice against using them. Just link everything statically and be happy for now. Kind Regards Benjamin Thaut
Jan 26