www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Loading Symbols from Loaded Libraries

reply "Matt" <webwraith fastmail.fm> writes:
If I were to use Runtime.loadLibrary(), it claims to merge any D 
GC in the shared lib with the current process' GC.

Do I need to version away symbol loading code for each platform?
Or is there already code in Phobos that allows us to do this 
independent of platform?
Sep 01 2014
parent "FreeSlave" <freeslave93 gmail.com> writes:
On Monday, 1 September 2014 at 13:31:32 UTC, Matt wrote:
 If I were to use Runtime.loadLibrary(), it claims to merge any 
 D GC in the shared lib with the current process' GC.

 Do I need to version away symbol loading code for each platform?
 Or is there already code in Phobos that allows us to do this 
 independent of platform?
There was high level Library wrapper by Martin Nowak ( https://github.com/MartinNowak/druntime/commit/f8f512edea2370759ab7 703dceece5e069645be ), but it seems it was not added to main dmd repository. So you should use dlsym / GetProcAddress. Use core.demangle.mangle to get mangled names of D functions. I also made some similar wrapper in my project https://bitbucket.org/FreeSlave/dido But it was not updated for a long time and now it's outdated (code uses dlopen and LoadLibrary which is wrong and should be changed to Runtime.loadLibrary. Same for dlclose and FreeLibrary)
Sep 01 2014