tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Linker and inter-library dependencies



I am having some trouble with inter-library dependencies.

A small C programs links against
/usr/pkg/java/openjdk7/jre/lib/i386/libjava.so.  libjava.so itself has
some dependencies, which are found in the same directory as libjava.so
itself and the client/ directory below:

netbsd5# ldd libjava.so

libjava.so:
        -ljvm => not found
        -lverify => not found
        -lc.12 => /usr/lib/libc.so.12

In my Makefile, I add the respective directories in which all shared
libraries can be found to the runtime linker search path using the -R
option:

---
SRCS=           invoke.c
PROG=           invoke

JDK=            /usr/pkg/java/openjdk7

CFLAGS+=        -I/usr/pkg/java/openjdk7/include

LDADD+=         -L${JDK}/jre/lib/${MACHINE} \
                -R${JDK}/jre/lib/${MACHINE} \
                -R${JDK}/jre/lib/${MACHINE}/client \
                -lpthread -ljava

NOMAN=          1

.include <bsd.prog.mk>
---

When I compile this and run ldd on the resulting binary, it still can
not resolve these libraries:

#   compile  jni/invoke.o
cc -O2 -I/usr/pkg/java/openjdk7/include   -Werror      -c
/home/mbalmer/src/jni/invoke.c
#      link  jni/invoke
cc           -o invoke  invoke.o -L/usr/pkg/java/openjdk7/jre/lib/i386
-R/usr/pkg/java/openjdk7/jre/lib/i386
-R/usr/pkg/java/openjdk7/jre/lib/i386/client  -lpthread -ljava
-Wl,-rpath-link,/lib  -L/lib -Wl,-rpath-link,/usr/lib  -L/usr/lib
obj/invoke:
        -lpthread.0 => /usr/lib/libpthread.so.0
        -lc.12 => /usr/lib/libc.so.12
        -ljava => /usr/pkg/java/openjdk7/jre/lib/i386/libjava.so
        -ljvm => not found
        -lverify => not found
        -ljvm => /usr/pkg/java/openjdk7/jre/lib/i386/client/libjvm.so
        -lgcc_s.1 => /usr/lib/libgcc_s.so.1
        -lstdc++.6 => /usr/lib/libstdc++.so.6
        -lm.0 => /usr/lib/libm.so.0

And when run, I just get the expected error message:

netbsd5$ obj/invoke
Shared object "libjvm.so" not found


How can this issue be resolved?




Home | Main Index | Thread Index | Old Index