I do have an application that requires linkage with libjvm
(a library from the JDK needed to do JNI bindings). When I tell the location of libjvm.dylib
using -L
it successfully compiles and links. However when I run the binary I get:
dyld: Library not loaded: @rpath/libjvm.dylib
Referenced from: <my home directory>/./mybinary
Reason: image not found
So far I found out that I can run my binary specifying LD_LIBRARY_PATH like so:
LD_LIBRARY_PATH=<path to libfolder installation> ./mybinary
But of course I do not want that. Why should I specify the exact location anyway if I have to give it again and again each time I start the application?!
I also learned that dynamic libraries on mac os x do get a kind of stamp which tells there location. However I don't know what rpath
is (seems like a variable to me, but how can I set it during linking?).
The application is built using haskell, but I can equally well link the object files manually using ld
. However, I'm stuck on that rpath thing - is it maybe special to the JDK libraries?
Here is what I do in order to build:
ghc --make Main.hs mycbinding.o -ljvm -L<javahome>/jre/lib/server -o mybinary