Forcing my module to be initialized first

dan dan.hitt at gmail.com
Mon Oct 16 04:28:22 UTC 2023


On Monday, 16 October 2023 at 03:33:55 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On 16/10/2023 4:31 PM, dan wrote:
>> I suppose if i could figure out a way to make all other 
>> modules depend on my module this would happen, but the module 
>> which uses the variable i want to set is in some 
>> already-compiled dynamic library that i would prefer not to 
>> touch.
>
> If its in a shared library, then that shared library gets setup 
> prior to your binary.
>
> There is nothing that you can do. You gotta override rather 
> than initialize.

Thanks Rikki.

I was wrong in my statement of the problem: it is not a dynamic 
library, but rather a static library, libgtkd-3.a.

I apologize for being so careless.

libgtkd-3.a throws an exception before main is reached, in the 
Loader.d file, in a method with signature 'public static void 
loadLibrary(string library)'.  That method is used trying to load 
a library which really is dynamic, libatk-1.0.0.dylib.  That 
library is in my system, among the Mac ports files, in a standard 
place, namely /opt/local/lib.  I can set the environment variable 
GTK_BASEPATH to help it out, and that works, but i would like to 
do all of this inside the executable rather than outside the 
executable.

The Loader.d file depends on std.process.

So, given that i was wrong and it is not a dynamic library i'm 
trying to get in ahead of, but a static one, is there a way to 
execute a small snippet of code after std.process is initialized, 
but before any other code (such as Loader.d) uses it?

Thanks in advance for any ideas.

dan


More information about the Digitalmars-d-learn mailing list