DYLD_FALLBACK_LIBRARY_PATH changed in OpenJDK (was Re: How to load dylib on Mac?)
Max (Weijun) Wang
Weijun.Wang at Sun.COM
Fri Jul 24 08:11:03 PDT 2009
In fact, why is DYLD_FALLBACK_LIBRARY_PATH updated in src/solaris/bin/
java_md.c? Why not DYLD_LIBRARY_PATH?
DYLD_LIBRARY_PATH should be preferred than DYLD_FALLBACK_LIBRARY_PATH.
If the libjpeg.dylib is in DYLD_LIBRARY_PATH, it will be loaded
instead of /usr/lib/libjpeg.dylib.
On Jul 24, 2009, at 4:52 PM, Weijun Wang wrote:
> Hi All
> I've found something new.
> It seems the dlopen() function in Mac is quite normal, but there are
> some problem inside OpenJDK.
> I'm calling dlopen("libkrb5.dylib", RTLD_NOW) inside OpenJDK now and
> returns NULL. However, if I manually set DYLD_LIBRARY_PATH or
> DYLD_FALLBACK_LIBRARY_PATH to /usr/lib, then it works.
> So I printf the DYLD_FALLBACK_LIBRARY_PATH value, it is changed to
> something like jre/lib/i386:jre/lib:jre/../lib/i386. According to
> doc, the default value of it should ~/lib:/usr/lib:/usr/local/lib. If
> OpenJDK wants to change it to something else, shouldn't it append the
> new value onto the old one?
> So I suggest making these changes:
> --- a/src/solaris/bin/java_md.c
> +++ b/src/solaris/bin/java_md.c
> @@ -443,6 +443,9 @@
> * variable.
> runpath = getenv(LD_LIBRARY_PATH);
> +#ifdef __APPLE__
> + if (!runpath) runpath = "/usr/local/lib:/usr/lib";
> #endif /* __solaris__ */
> #if defined(__linux__) || defined(_ALLBSD_SOURCE)
> Yes, the default runpath should also include "~/lib", omitted here for
> Max (Weijun) Wang wrote:
>> Hi All
>> I'm totally new to C programming on Mac.
>> On other systems I can call dlopen("libkrb5.so", RTLD_NOW) to
>> return a
>> non-NULL pointer to the library. However, on Mac,
>> dlopen("libkrb5.dylib", RTLD_NOW) returns NULL even if I can see
>> the /
>> usr/lib/libkrb5.dylib is right there. What's wrong here?
>> Also, is there a way to write a cross-platform call? Say,
> I've found the JNI_LIB_NAME() macro. Nice.
More information about the bsd-port-dev