[vtkusers] Wrapping Java

Daniel Sáez Domingo dsaez at iti.upv.es
Tue Apr 30 05:11:16 EDT 2002


Yes, I got to create the .jnilib from the .o files but when execute the java 
program it's produced a Bus error. I don't know what this error means.

I have tried to create the jnilib from the cxx and I have done the next in 
every directory:

 c++ -bundle -g -O2 -fno-coalesce-templates -fno-coalesce-static-vtables 
-DvtkCommonJava_EXPORTS -I/usr/local/src/VTK/Common 
-I/usr/local/src/VTK/Rendering -I/usr/local/src/VTK 
-I/usr/local/src/VTK/Common -I/usr/local/src/VTK/Filtering 
-I/usr/local/src/VTK/Imaging -I/usr/local/src/VTK/Graphics 
-I/usr/local/src/VTK/IO -I/usr/local/src/VTK/Utilities/zlib 
-I/usr/local/src/VTK/Utilities/png -I/usr/local/src/VTK/Utilities/jpeg 
-I/usr/local/src/VTK/Common/Testing/Cxx 
-I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers 
-I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers 
-I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/ 
-I/System/Library/Frameworks/JavaEmbedding.framework/Versions/A/Headers 
-DVTK_USE_QUARTZ -o /usr/local/src/VTK/lib/libvtkCommonJava.jnilib *Java.cxx 
vtkJavaUtil.cxx -L/usr/local/src/VTK/lib/ -L/usr/local/src/VTK/bin/ -lpthread 
-lm -lvtkCommon

but when I do:

[$] #cd /usr/local/src/VTK/Examples/Tutorial/Step1/Java
[$Step1] #setenv CLASSPATH .:/usr/local/src/VTK/java
[$Step1] #setenv DYLD_LIBRARY_PATH /usr/local/src/VTK/lib
[$Step1] #setenv LD_LIBRARY_PATH /usr/local/src/VTK/lib
[$Step1] #javac Cone.java
[$Step1] #java Cone
Bus error

The same Bus error.
I don't know the cause of this error.

Could enybody help me, please?
Thanks
Daniel Sáez

El Lun 29 Abr 2002 17:54, Jeff Lee escribió:
> You also need to link in libvtkCommon.dylib - try a) and link in
> libvtkCommon.dylib.  The same goes for all other *Java.jnilib libraries
> - you must link in the corresponding base lib.
> -Jeff
>
> Daniel Sáez Domingo wrote:
> >Hi Jeff,
> >
> >   I've tried to create the jnilib like you has said but I have some
> > error. Perhaps you would know how solve it.
> >I've tried two ways and both have the same final.
> >a) Like I have all the .o of the source files that are going to make the
> >
> >library, I do:
> >:src/VTK/Common$# c++ -bundle
> >
> >-I/System/Library/Frameworks/JavaVM.framework/Headers -o
> >libvtkCommonJava.jnilib -framework JavaVM *Java.o
> >
> >and the eror is:
> >/usr/bin/ld: Undefined symbols:
> >_AddClippingPlane__17vtkAbstractMapperP8vtkPlane
> >_RemoveAllClippingPlanes__17vtkAbstractMapper
> >_RemoveClippingPlane__17vtkAbstractMapperP8vtkPlane
> >_SetClippingPlanes__17vtkAbstractMapperP9vtkPlanes
> >_ShallowCopy__17vtkAbstractMapperPB0
> >_vtkJavaCreateNewJavaStubForObject__FP7JNIEnv_P9vtkObject
> >_vtkJavaCreateNewJavaStub__FP7JNIEnv_PCcPv
> >_vtkJavaGetId__FP7JNIEnv_P8_jobject
> >_vtkJavaGetObjectFromPointer__FPv
> >_vtkJavaGetPointerFromObject__FP7JNIEnv_P8_jobjectPc
> >_vtkJavaMakeJavaString__FP7JNIEnv_PCc
> >_vtkJavaRegisterCastFunction__FP7JNIEnv_P8_jobjectiPv
> >_vtkJavaUTFToChar__FP7JNIEnv_P8_jstring
> >_DeepCopy__20vtkAbstractTransformPB0
> >_GetGlobalWarningDisplay__9vtkObject
> >_GetInverse__20vtkAbstractTransform
> >_SetInverse__20vtkAbstractTransformPB0
> >.......goes on
> >
> >b)I compile all another time doing:
> >:src/VTK/Common$#  c++ -bundle
> >
> >-I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/src/VTK
> > -o libvtkCommonJava.jnilib -framework JavaVM *Java.cxx
> >
> >but the same error appears.
> >
> >How can I solve this error?
> >
> >Thanks
> >
> >El Lun 29 Abr 2002 14:03, escribió:
> >>OK, so java on mac needs a .jnilib.  Did you try renaming the vtk*Java
> >>libs to have extension .jnilib?  Or better yet, something like below,
> >>linking libvtkCommon.dylib and libvtkCommonJava.dylib to
> >>libvtkCommonJava.jnilib?
> >>-Jeff
> >>
> >><excerpt>
> >>JNI libraries are always named |lib|/|name|/| .jnilib|, where /|name|/
> >>is the value of the string used in the call to |System.loadLibrary()|.
> >>For example, to load the library named |libhello.jnilib|, you would make
> >>
> >>the following call in your Java code:
> >>    |System.loadLibrary("hello");|
> >>
> >>To build a JNI library, execute the following command:
> >>
> >>    *|$|*| cc -bundle
> >>    -I/System/Library/Frameworks/JavaVM.framework/Headers -o
> >>    lib|/|name|/|.jnilib -framework JavaVM |/|sourceFiles|/
> >>
> >>For example, if the files |hello.c| and |goodbye.c| contain the
> >>implementations of the native methods to be built into |
> >>libhello.jnilib|, you would build |libhello.jnilib| with the following
> >>command:
> >>
> >>    *|$|*| cc -bundle
> >>    -I/System/Library/Frameworks/JavaVM.framework/Headers -o
> >>    libhello.jnilib -framework JavaVM hello.c goodbye.c|
> >>
> >>A common problem for JNI developers is that JNI dynamic libraries have
> >>interdependencies. For example: libA.jnilib contains a function foo().
> >>libB.jnilib needs to link against libA.jnilib to make use of foo(). This
> >>will not work on Mac OS X because JNI libraries are bundles (all symbols
> >>are private to a bundle). One solution to this dependency problem is to
> >>put the common functions into a separate dynamic library (libC.dylib in
> >>this example) and link both libA.jnilib and libB.jnilib to libC.dylib.
> >>
> >>Daniel Sáez Domingo wrote:
> >>>Hi Jeff,
> >>>
> >>>  I have tested my system and I know that the java.library.path contains
> >>>the path to the directory where the .dylib are. But the problem is that
> >>>MacOSX doesn't understand .dylib but it only understands .jnilib when we
> >>>do a System.loadLibrary() call. Then I want to know how to convert
> >>> .dylib into .jnilib.
> >>>
> >>>Thanks
> >>>Daniel Sáez
> >>>
> >>>El Lun 29 Abr 2002 13:38, escribió:
> >>>>Hi Daniel,
> >>>>What are the contents of DYLD_LIBRARY_PATH?  Also, (I'm not familiar
> >>>>with macos) does setting LD_LIBRARY_PATH to /usr/local/src/VTK/bin (or
> >>>>equivalent location of your shared libraries) help?
> >>>>-Jeff
> >>>>
> >>>>Daniel Sáez Domingo wrote:
> >>>>>The error is:
> >>>>>
> >>>>>Exception in thread "main" java.lang.UnsatisfiedLinkError: no
> >>>>>vtkCommonJava in java.library.path
> >>>>>      at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
> >>>>>      at java.lang.Runtime.loadLibrary0(Runtime.java:749)
> >>>>>      at java.lang.System.loadLibrary(System.java:820)
> >>>>>      at vtkPanel.<clinit>(vtkPanel.java:22)
> >>>>>
> >>>>>and my DYLD_LIBRARY_PATH is:
> >>>>>
> >>>>>DYLD_LIBRARY_PATH=/usr/local/src/VTK/lib:/usr/local/src/VTK/bin
> >>>>>
> >>>>>Daniel Sáez
> >>>>>
> >>>>>El Lun 29 Abr 2002 13:24, escribió:
> >>>>>>No, what is the error exactly - what is the stack trace?  Also, what
> >>>>>> is your DYLD_LIBRARY_PATH?
> >>>>>>-Jeff
> >>>>>>
> >>>>>>Daniel Sáez Domingo wrote:
> >>>>>>>UnsatisfiedLinkError is produced when the library that we are trying
> >>>>>>>to load doesn't exist in java.library.path property. But I think
> >>>>>>> that this error is produced because I have .dylib libraries instead
> >>>>>>> .jnilib that are necessary for System.loadLibrary() java call.
> >>>>>>>
> >>>>>>>Daniel Sáez
> >>>>>>>
> >>>>>>>El Lun 29 Abr 2002 13:15, escribió:
> >>>>>>>>What is the unsatisfied link error?
> >>>>>>>>-Jeff
> >>>>>>>>
> >>>>>>>>Daniel Sáez Domingo wrote:
> >>>>>>>>>Hello,
> >>>>>>>>>
> >>>>>>>>>I have a problem loading libraries in Java. I'll explain it.
> >>>>>>>>>
> >>>>>>>>>I have ported VTK into Mac OSX using only Quartz and wrapping
> >>>>>>>>> Java. It generates libraries named libnameJava.dylib from a great
> >>>>>>>>> number of files. I have included the DYLD_LIBRARY_PATH with the
> >>>>>>>>> path to these libraries. Then, when a
> >>>>>>>>> System.loadLibrary("nameJava") call is done, it's produced an
> >>>>>>>>> UnsatisfiedLinkError.
> >>>>>>>>>I have read that the System.loadLibrary() call needs a .jnilib
> >>>>>>>>>library, but I don't know how to create it from a dylib library
> >>>>>>>>>(this option would be the best) or from the source files. I don't
> >>>>>>>>>either know if I have to create both jnilib and dylib libraries
> >>>>>>>>>because I don't know if the dylib library is going to be used.
> >>>>>>>>>
> >>>>>>>>>I would thank somebody help me.
> >>>>>>>>>
> >>>>>>>>>Daniel Sáez
> >>>>>>>>>_______________________________________________
> >>>>>>>>>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://public.kitware.com/mailman/listinfo/vtkusers
> >
> >_______________________________________________
> >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://public.kitware.com/mailman/listinfo/vtkusers



More information about the vtkusers mailing list