I am using setenv to set DYLD_LIBRARY_PATH so when I do a dlopen() it will have the correct paths to find my .dylib, but when I do the dlopen() it doesn't seem to search the paths that I added to DYLD_LIBRARY_PATH.
From what I can gather my changes to DYLD_LIBRARY_PATH won't take effect until a re-execute my process happens. Is this correct?
Also if that is correct, is there a way to set DYLD_LIBRARY_PATH and having my changes work with out doing a reset of my process.
Oh yeah I writing this code on MAC OSX.
Thanks in advance.
I don't know about Mac OS, but on Linux, the loader reads the value of getenv("LD_LIBRARY_PATH")
once, and saves it away, long before the first instruction of your executable runs. Subsequent modification of LD_LIBRARY_PATH
by the program only affects any children it execve()
s, but not the process itself. I imagine it's similar on Mac OS.
The usual way around this is to either re-execve
the proces (Java does this), or to use a shell wrapper which sets the environment and then exec's the real binary (Firefox does that).
There might be a Mac OS specific way to update the library search path, though Google doesn't seem to find any matches. I am pretty sure there isn't any such mechanism on Linux.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With