[fedora-java] Shared library paths for native linker

Petr Pisar ppisar at redhat.com
Tue Sep 27 14:52:29 UTC 2011


Hello,

I have a non-java package (pl) which links to jvm. Build scripts of pl
needs to locate directories with libjava.so, libjvm.so etc. and instruct
native linker (ld) where to find them (-L option).

Current implementation in the pl.spec is uggly (a lot of ad-hoc hacks for
each platform which requires tuning time to time
<https://bugzilla.redhat.com/show_bug.cgi?id=740897>).

So I decided to find ultimate way how to obtain path for linker and Java
home directory. Unfortunatelly, I did not find any. So I've written
one. You can find it as attachment at the afore-mentioned bug report.

Usage is inspired by pkg-config:

$ javac JavaConfig.java
$ java JavaConfig --home
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
$ java JavaConfig --libs-only-L
-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server
-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64
-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64
-L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib64 -L/lib -L/usr/lib

I can bundle the tool to my `pl' package, but I think it could be
helpful for others too. So I'd like to ask Java SIG whether it wants to
adopt it (e.g. as a part of JDK).

-- Petr




More information about the java-devel mailing list