Opened 18 years ago

Closed 18 years ago

#2182 closed defect (fixed)

Building graphviz-2.8 with Java Bindings

Reported by: teewan@… Owned by: Randy McMurchy
Priority: normal Milestone: 6.2.0
Component: BOOK Version: SVN
Severity: normal Keywords: graphviz java bindings
Cc:

Description

graphviz-2.8's configure script does not seem to properly find your Java headers (i.e. jni.h) unless they are specifically located in your /usr/include directory.

Simply passing configure a CPPFLAGS doesn't seem to do the trick, as the generated Makefiles still do not reference the additional include and library directories passed to it.

A solution that seems to have worked for me is to run the following in the graphviz build directory (the one created by the tar command):

CPPFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux" \
./configure --prefix=/usr &&
make JAVA_LIBS="$JAVA_HOME/lib" JAVA_INCLUDES="$JAVA_HOME/include"

And then, as supplied by BLFS (as user root):

make install

and optionally

ln -v -s /usr/share/graphviz/doc \
         /usr/share/doc/graphviz-2.8

Note: You must (and already should if you followed the BLFS instructions for configuring JDK) have an environment variable JAVA_HOME which references the prefix for your JDK installation.

Change History (4)

comment:1 by teewan@…, 18 years ago

As of today's (12 Oct 2006) development snapshot, graphviz-2.9's configure script has gotten a bit better. It still won't find your Java includes unless you supply the CPPFLAGS override to configure, but it will actually populate JAVA_LIBS and JAVA_INCLUDES variables in the Makefiles if you do supply the CPPFLAGS listed above.

comment:2 by Randy McMurchy, 18 years ago

Owner: changed from blfs-book@… to Randy McMurchy
Status: newassigned

I spent a few minutes trying to duplicate this issue and was stumped as configure found and processed the jni.h header just fine. Compilation of the package (including the JAVA bindings) was perfect. Looking further, the specific autoconf function is an AC_CHECK_HEADER call for jni.h.

Easy enough. However, I was totally stumped on how configure was finding /opt/jdk/include/jni.h. I spent a few more minutes trying to figure out how configure knew to look in JAVA_HOME/include. I couldn't find anything, so I wrote a bogus configure.ac with some AC_CHECK_HEADER calls. Finally, after a lucky error message, I see that configure will use the /usr/lib/gcc/.../include directory in the search directories for system headers.

And, because my GCC installation includes the JAVA compiler, configure finds jni.h. So, this explains why Graphviz builds the JAVA bindings just fine *for me*, and could fail for others.

But, I need someone to check out another method of discovery other than what is proposed earlier in this ticket. There is a native method of including additional search directories for headers and libs using the --with-extraincludedir and --with-extralibdir parameters passed to configure.

As I cannot check this (due to having GCC's JAVA compiler installed), could someone who has the JDK installed (and not GCC's java) please use these parameters to configure and see if it works? Unfortunately, you'll also need SWIG installed.

comment:3 by Randy McMurchy, 18 years ago

A bit more on this one:

I renamed my existing GCC version of the jni header so that configure would not find it. Good so far, and the JAVA bindings don't get created as configure doesn't know to look in $JAVA_HOME.

Now I'm not sure that the JAVA_LIBS or JAVA_INCLUDES vars even need to be set. I can compile just fine with them being empty. Best I can tell they serve no purpose.

I simply run the following sed before building the package IAW the BLFS book and it seems to be fine. Unless there is some objection (then please reopen this ticket), I am going to update the Graphviz instructions to include the following sed command:

{{ sed -i 's|JAVA_LIBS=|& \ if test -n "$JAVA_HOME"; then \

CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include -I$JAVA_HOME/include/linux" \

fi|' configure }}

This simple sed adds enough to the configure script so that it can find and utilize the JDK and build the JAVA bindings.

comment:4 by Randy McMurchy, 18 years ago

Resolution: fixed
Status: assignedclosed

Added the sed command to the BLFS Graphviz instructions

Note: See TracTickets for help on using tickets.