Shared libraries/DLLs

Neal Alexander wqeqweuqy at hotmail.com
Sun Feb 3 18:04:35 PST 2008


Jarrett Billingsley wrote:
> "Unknown W. Brackets" <unknown at simplemachines.org> wrote in message 
> news:fo0p7c$1tbq$1 at digitalmars.com...
>> Okay.
>>
>> Example "plugin" example.d:
>>
>> ---
>> module example;
>>
>> extern (C)
>> export int foo();
> 
> Ohhh, _there_ it is; I think this bit got cut out of the original post :)
> 
>> I don't have the Linux loader in front of me but it's almost exactly the 
>> same and works just fine (LoadLibraryA => dlopen, GetProcAddress => dlsym, 
>> FreeLibrary => dlclose, with some dlerror logic in there.)  But as stated, 
>> it appears that there's really no "reverse linking" of DLLs.
> 
> As in having DLLs link to symbols exported from the app?  Right, it's not 
> possible without some hackery.  I'm not sure how to do it but apparently it 
> can be done.  I think there are restrictions on it, though.
> 
> DLLs really *are* an awful approximation of SOs :( 
> 
> 

Ive never had problems resolving an .exe's exported symbols at runtime. 
Dunno why it would be an issue doing it from inside a DLL.

x = GetModuleHandle(NULL); // handle to image that created the process
GetProcAddress(x, "foo_"); // or "foo" depending how the compiler 
generates C symbols


More information about the Digitalmars-d-learn mailing list