[vtkusers] Wrapping Java

Jeff Lee jeff at cdnorthamerica.com
Mon Apr 29 11:54:34 EDT 2002


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

-- 
Jeff Lee 
Software Engineer jeff at cdnorthamerica.com
CD North America
21 Lafayette Street, Suite 230
Lebanon, NH 03766
Tel:    (603) 643-9993 ext. 109
Fax:    (603) 643-9994 






More information about the vtkusers mailing list