Desperately looking for a work-around to load and unload D shared libraries from C on OSX
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 17 14:13:44 PDT 2015
On Thursday, 17 September 2015 at 20:47:49 UTC, Jacob Carlborg
wrote:
> On 2015-09-17 21:42, bitwise wrote:
>
>> Ok, but this kinda defeats the purpose, as the op wants to
>> unload the
>> library ;)
>
> He said he doesn't want dlopen to crash, if it doesn't unload
> it fixes the problem ;)
True. Looking at his bug report now, it seems his dylib is a VST
plugin. Had he just said that to begin with, this conversation
would have been a lot easier -_-
The op shouldn't have to actually modify druntime in this case.
He shouldn't have to replace "_dyld_register_func_for_add_image".
He can simply create a second empty callback in VSTPluginMain
which will pin his library:
static bool didInitRuntime = false;
const char* ignoreImageLoad(
enum dyld_image_states state,
uint32_t infoCount,
const struct dyld_image_info info[])
{
// ignore.
}
extern(C) void* VSTPluginMain(void* hostCallback)
{
import core.runtime;
if(!didInitRuntime)
{
Runtime.initialize();
dyld_register_image_state_change_handler(
dyld_image_state_initialized,
&ignoreImageLoad);
didInitRuntime = true;
}
import std.stdio;
import core.stdc.stdio;
printf("Hello !\n");
// Runtime.terminate();
return null;
}
Bit
More information about the Digitalmars-d
mailing list