Java compilation error : /bin/ld:cannot find -ljvm
Asked Answered
C

1

6

I am trying to build a java project http://sourceforge.net/projects/fuse-j/?source=typ_redirect on fedora machine. The compilation fails while compiling JNI bindings.

MakeFile

include ../build.conf
include ../jvm_ldpath.def

SRCS := javafs.c javafs_bindings.c
HDRS := javafs.h javafs_bindings.h
LIB_SO := libjavafs.so

INCLUDES := -I${FUSE_HOME}/include -I${JDK_HOME}/include    -I${JDK_HOME}/include/linux

LDPATH := ${LDPATH} -L${FUSE_HOME}/lib


all: ${LIB_SO}

${LIB_SO}: ${SRCS} ${HDRS}
gcc -fPIC -shared -D_FILE_OFFSET_BITS=64 -o ${LIB_SO} ${INCLUDES} ${LDPATH}   -ljvm -lfuse -lpthread ${SRCS}

clean:
   rm -f ${LIB_SO}

Error:

/bin/ld: cannot find -ljvm
collect2: error: ld returned 1 exit status
Makefile:17: recipe for target 'libjavafs.so' failed
make[1]: *** [libjavafs.so] Error 

JDK_HOME ,FUSE_HOME are correctly set. Can you suggest what can be wrong here?

Communicable answered 26/5, 2015 at 14:27 Comment(0)
B
5

The jvm shared library will be found in a path under $JDK_HOME, however, you are not adding that path to your LDPATH make variable. You need to add -L${JDK_HOME}/lib to LDPATH (or wherever libjvm.so is found).

Belshazzar answered 29/5, 2015 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.