Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java compilation error : /bin/ld:cannot find -ljvm

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?

like image 270
WillMcavoy Avatar asked Oct 31 '22 03:10

WillMcavoy


1 Answers

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).

like image 169
technomage Avatar answered Nov 15 '22 04:11

technomage