[vtkusers] Problem building VTK with Java 1.5 - how to link in libmawt.so?
Jarek Sacha
jarek at ieee.org
Sun Mar 7 15:08:55 EST 2004
Jeff Lee wrote:
> in jdk1.5 (on linux and solaris) there is a choice of whether to use
> xawt or old motif toolkit. Xtoolkit is the default, so it should
> probably point to /usr/java/j2sdk1.5.0/jre/lib/i386/xawt/libmawt.so.
> To get it to go temporarily, you could just put this lib in your
> LD_LIBRARY_PATH while building, but there is the bigger issue of how
> to put this into cmake. This issue also exists in a solaris build
> that needs libmawt.so to resolve other symbols during link.
I have a hack to compile with 1.5.0 by adding lines
IF(EXISTS ${JAVA_LIB_DIR}/xawt)
LINK_DIRECTORIES(${JAVA_LIB_DIR}/xawt)
ENDIF(EXISTS ${JAVA_LIB_DIR}/xawt)
to Wrapping/Java/CMakeLists.txt, about line 51, the fragment of code
after modification looks like this:
IF(JAVA_AWT_LIBRARY)
GET_FILENAME_COMPONENT(JAVA_LIB_DIR ${JAVA_AWT_LIBRARY} PATH)
IF(EXISTS ${JAVA_LIB_DIR}/xawt)
LINK_DIRECTORIES(${JAVA_LIB_DIR}/xawt)
ENDIF(EXISTS ${JAVA_LIB_DIR}/xawt)
IF(EXISTS ${JAVA_LIB_DIR}/client)
LINK_DIRECTORIES(${JAVA_LIB_DIR}/client)
ENDIF(EXISTS ${JAVA_LIB_DIR}/client)
ENDIF(JAVA_AWT_LIBRARY)
SET(CMAKE_SKIP_RPATH 0)
ADD_EXECUTABLE(VTKJavaExecutable VTKJava.cxx)
SET(JAVA_LIBRARIES)
I do not know enough about CMake to make it general. This should be
something more elaborated so there is an option to choose whether the
new xawt or old motif binding is used (xawt selected by default on Linux
and motif by default on Solaris).
Bottom line is that the code compiles:) There is some problem with code
execution, by "default" I am getting runtime error or JVM crash with
error message:
"Runtime link error - it appears that libXt got loaded before libXm,
which is not allowed."
This error happens then System.load("vtkRnderingJava") is executed,
loading any other VTK library goes OK. I filed bug report with Sun,
though I am not clear if this is a bug in Java 1.5.0 or a VTK specific
issue.
A workaround is to preload the Xm library, for instance, rather that typing
$ java SimpleVTK
type
$ LD_PRELOAD=/usr/X11R6/lib/libXm.so java SimpleVTK
There must be some better way than above, hopefully something that can
be handled by CMake configuration. Any thoughts on that?
Jarek
>
> Jarek Sacha wrote:
>
>> The basic question is how to add a new system library to link to java
>> wrappers while building VTK?
>> This is probably a very silly CMake question. (It is very VTK
>> related, I am not sure if it is a question for VTK or for CMake list.)
>>
>> I am trying to compile VTK with Java wrappers on Fedora Linux and
>> Java 1.5.0. All the configuration goes fine. During build I am
>> getting an error:
>> ...
>> Building executable /home/local/src/VTK-build/bin/VTKJavaExecutable...
>> /usr/bin/ld: warning: libmawt.so, needed by
>> /usr/java/j2sdk1.5.0/jre/lib/i386/libjawt.so, not found (try using
>> -rpath or -rpath-link)
>> /usr/java/j2sdk1.5.0/jre/lib/i386/libjawt.so: undefined reference to
>> `awt_Unlock at SUNWprivate_1.1'
>> /usr/java/j2sdk1.5.0/jre/lib/i386/libjawt.so: undefined reference to
>> `awt_GetComponent at SUNWprivate_1.1'
>> /usr/java/j2sdk1.5.0/jre/lib/i386/libjawt.so: undefined reference to
>> `awt_GetDrawingSurface at SUNWprivate_1.1'
>> /usr/java/j2sdk1.5.0/jre/lib/i386/libjawt.so: undefined reference to
>> `awt_FreeDrawingSurface at SUNWprivate_1.1'
>> /usr/java/j2sdk1.5.0/jre/lib/i386/libjawt.so: undefined reference to
>> `awt_Lock at SUNWprivate_1.1'
>> collect2: ld returned 1 exit status
>> make[3]: *** [/home/local/src/VTK-build/bin/VTKJavaExecutable] Error 1
>> make[2]: *** [default_target] Error 2
>> make[1]: *** [default_target_Wrapping_Java] Error 2
>> make: *** [default_target] Error 2
>>
>> Looks that this version of Java is using a new libmawt.so library.
>> There are three versions of this library in Java 1.5.0, located in:
>> /usr/java/j2sdk1.5.0/jre/lib/i386/xawt/libmawt.so
>> /usr/java/j2sdk1.5.0/jre/lib/i386/headless/libmawt.so
>> /usr/java/j2sdk1.5.0/jre/lib/i386/motif21/libmawt.so
>>
>> How to modify VTK/Wrappers/CMakeLists.txt to add linking of Java
>> wrappers to an additional library? In this case the libmawt.so.
>> Is there a need to modify any other, for instance ,
>> VTK/Rendering/CMakeLists.txt?
>>
>> Thanks,
>>
>> Jarek
>>
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages
>> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
More information about the vtkusers
mailing list