[vtkusers] Compiling VTK + JAVA on solaris

William A. Hoffman billlist at nycap.rr.com
Thu Dec 9 08:51:37 EST 2004

libvtkCommonJava.so needs to link to libCrun.
When most C++ compilers create a shared library they
automatically add the c++ run time library to the link line.
However, the sun compiler does not seem to do that.
So, I think it can be fixed with a small change to the
CMakeLists.txt files in VTK.

In the top level VTK CMakeLists.txt file, after this comment:
# VTK requires special compiler flags on some platforms.

Add this:

# make sure Crun is linked in with the native compiler, it is
# not used by default for shared libraries and is required for
# things like java to work.

Then remove bin/*.so and re-link all the shared libraries.
It should fix the problem.  I have checked the fix into
cvs VTK, but it should work with any other version as well.


At 07:22 AM 12/9/2004, Andrew Watkins wrote:

>I have been trying for over the last week to compile VTK 4.4.2 or 4.2.6 with Java
>and have failed many times with different errors.
>If any one has a complete guide it would be very usefull, since I am sure I am not the only 
>Current problem is that I FINNALY got it to complile with no errors, but when I try the 
>test programs I get errors:
>Solaris 9/openGL 1.3/gcc 3.3/Java 1.4.2_06/VTK 4.4.2 
>(Have tried Java 1.5 and gcc 2.95.3)
>% cd /tmp
>% cmake -i
>  Main options I set:
>        JAVACOMMAND=/usr/j2se/bin/java
>        JAVA_ARCHIVE=/usr/j2se/bin/jar
>        JAVA_AWT_INCLUDE_PATH=/usr/j2se/include
>        JAVA_AWT_LIBRARY=/usr/j2se/jre/lib/sparc/libjawt.so
>        JAVA_COMPILE=/usr/j2se/bin/javac
>        JAVA_INCLUDE_PATH=/usr/j2se/include
>        JAVA_INCLUDE_PATH2=/usr/j2se/include/solaris
>        JAVA_RUNTIME=/usr/j2se/bin/java
>% gmake -i
>% gmake install
>% cd java/vtk
>% java *.java
>% cd ..
>% jar cvf vtk.jar vtk/*.class
>% echo $CLASSPATH
>  .:/tmp/VTK/java/vtk.jar
>  /opt/gnu/lib:/opt/vtk/lib/vtk:/opt/SUNWspro9/lib:/usr/openwin/lib
>% cd /tmp/VTK/Wrapping/Java
>% javac SimpleVTK.java
>% java SimpleVTK
>Exception in thread "main" java.lang.UnsatisfiedLinkError: 
>/bbkdcs/vtk/lib/vtk/libvtkCommonJava.so: ld.so.1: java: fatal: relocation error: file 
>/bbkdcs/vtk/lib/vtk/libvtkCommonJava.so: symbol _ZSt4cout: referenced symbol not found
>        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
>        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
>        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511)
>        at java.lang.Runtime.loadLibrary0(Runtime.java:788)
>        at java.lang.System.loadLibrary(System.java:834)
>        at vtk.vtkPanel.<clinit>(vtkPanel.java:26)
>        at SimpleVTK.<init>(SimpleVTK.java:19)
>        at SimpleVTK.main(SimpleVTK.java:49)
>% javac Regression.java
>Regression.java:21: cannot resolve symbol
>symbol  : method Initialize (java.lang.String[])
>location: class vtk.vtkTesting
>    vtkTesting.Initialize(args);
>              ^
>Regression.java:95: cannot resolve symbol
>symbol  : variable PASSED 
>location: class vtk.vtkTesting
>    int retVal0 = vtkTesting.PASSED;
>                            ^
>Regression.java:108: cannot resolve symbol
>Any pointers would be great!!!
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:

More information about the vtkusers mailing list