Search code examples
environment-variablesdlopendyldsetenv

Problems with using setenv and then making the dlopen call


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.


Solution

  • The answer to my question is no you can't use setenv without doing a re-execute of the process on LD_LIBRARY_PATH for the environmental variable to take an effect on dlopen.

    I found out that you should use @exectuable_path, @loader_path, or @rpath as an install name path on my .dylb is this way you can do a relative path search on your .dylibs from dlopen.