[vtkusers] VTK+java built on MinGW: recent experience?

Steve Robbins smr at sumost.ca
Thu Dec 7 17:12:12 EST 2006


Hello,

I've just succeeded to build VTK (with java wrappers) using MinGW.   
But I had to make 4 gross hacks so I'm wondering whether I've done  
something wrong.  The last threads I could find on this list were from  
last March and none of what I read apply to my experience, though bug  
#2952 (http://www.vtk.org/Bug/bug.php?op=show&bugid=2952&pos=5) does  
apply.

I'm building the CVS trunk of VTK as of about 11:30 CST today, using  
CMake 2.4.5.

1. The first thing I ran into is that Common/vtkJavaUtil.cxx includes  
<mapiform.h>, which doesn't exist -- see bug #2952.  I simply removed  
that line.

2. The next thing was a redefinition of "boolean".  This is defined in  
Utilities/vtkjpeg/jmorecfg.h as an int, but <rpcndr.h> as a char.  It  
turns out that inclusion of <rpcndr.h> can be suppressed by defining  
the C preprocessor symbol WIN32_LEAN_AND_MEAN.  I can't understand why  
nobody reported this error before.

At this point, everything built and I installed it into C:\Program  
Files\VTK-cvs.  I compiled Cone.java from Examples/Tutorial/Step1.   
Even after getting the PATH right, it didn't run; there were link  
errors at this line in the code:

     System.loadLibrary("vtkCommonJava");

3. The problem turns out to be that the JNI library was installed as  
"libvtkCommonJava" rather than simply "vtkCommonJava".  I am suprised  
by this.  The bug report #2952 (from March) has a note:

  Posted by: brad dot king at kitware dot com
  Date: 5:12 PM 03-16-2006
  [...]
  The loaded command problem is due to a bug in CMake which I've now fixed in
  CVS.  It was improperly computing the name of shared modules when loading the
  command on MinGW.

I had assumed by this note that CMake 2.4.5 (released in May) would  
properly compute DLL names.  Did I misread it?  In any case, I had to  
change all the java System.loadLibrary calls to load  
"libvtkCommonJava", etc.  I haven't found any other similar reports so  
am I doing something wrong?

4. After all that, the program successfully loads all the libraries,  
only to die at the line

     vtkConeSource cone = new vtkConeSource();

with a link error, being unable to find method VTKInit() -- the first  
native method called.  Again, I can't understand why this hasn't been  
reported here.  I must be doing something really dumb.  I finally  
stumbled upon the --add-stdcall-alias flag (thanks to  
http://www.inonit.com/cygwin/jni/helloWorld/c.html).  Now Cone.java  
compiles and runs.  Yay!


So what are other folks' recent experiences with VTK+java wrappers+MinGW?

Thanks,
-Steve




More information about the vtkusers mailing list