Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java JNI and DYLIB problem



On Sunday, Aug 31, 2003, at 19:11 US/Eastern, Bill Northcott wrote:

1. Searching for libs at runtime is intentionally different from the
search at static link time.

well, I didn't remember I said something about static link time
of course searching for dynamic libraries at runtime is different from the search
for static libraries at building time (link phase)
so what?


2. In order for an app to run, all jnilibs and any dylibs they use must be
in the default dyld search path or the DYLD_LIBRARY_PATH environment
variable.


jnilib:
first of all JVM looks for the jnilib in the path defined in the property java.library.path and only
if it's not able to find there it will look for jnilibs in the path in the DYLD_LIBRARY_PATH variable
so that environment variable has to be set before java program is running,
but remember: the most convenient way to define path for searching jnilibs is java.library.path
dylibs is another story: JVM doesn't load dylibs (BTW: in Jaguar and later jnilib could be created as dynamic library but it should be a bundle anyway,
for 10.0 jnilib must be a bundle, not dynamic library), AFAIK dylibs loads dynamic linker.

dylib
when you build jnilib that will use dylib at runtime static linker records information about install path (name) of the dylib into the jnilib
(from Apple's documentation:
The install name is the pathname used by the dynamic linker to find a shared library at runtime. The install name is defined by the shared library and recorded into the client program (in our case it's jnilib - D.M. ) by the static linker.)

if dylib won't be found in that path dynamic linker will search the directories
from DYLD_LIBRARY_PATH

I'd avoid using DYLD_LIBRARY_PATH from java application

you can use the -L option to otool to discover the frameworks and shared libraries that the jnilib is linked against

Dmitry Markman
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.