[vtkusers] Mac OS X, Java guru needed, please.

Mike Jackson mike.jackson at imts.us
Thu Jan 18 11:43:38 EST 2007


And just following up with what I did to get Java/Vtk working together:

I am guessing somewhere in the CMakeLists.txt files for vtk there is  
a missing link library (-framework JavaVM) for those that need it. I  
manually edited the link.txt file to add this and the compile went  
ok. As far as changing values in ccmake I changed the following:

Build Shared libs: ON
Build Cocoa: ON (Java 1.4 and above in OS X is based on Cocoa, NOT  
Carbon.. although I would think Carbon might work also since VTKJava  
is simply passing through JNI for the calls)
RPATH: ON
Testing: OFF
Examples: OFF
Java Wrapping: ON
Carbon: OFF
X: OFF

When I built I had to use a single compile thread (make) instead of  
the usual make -j 3 that I use.. odd

When everything is built I COPIED the the vtk.jar file into /Library/ 
Java/Extensions as this is a default location that OS X will look for  
java jar files.

Now drill down into the $VTKSource/Wrapping/java and issue the  
following command:
javac SimpleVTK.java
This _should_ compile at this point.
Now to run the program, since we turned ON RPATH we need to tell java  
where to find additional libraries so:

java -Djava.library.path=/Users/Shared/OpenSource/vtkjava/bin/ SimpleVTK

and that popped up a window with a cone and allowed interaction. Yeah...

There are a couple of ways to do this slightly cleaner: (none of this  
is tested)

Turn OFF RPATH and then copy ALL the built libraries and jar files  
into /Library/Java/Extensions
That should allow java programs to execute with out have to manually  
set the -Djava.library.path value each time:

You can in your .bash_profile file in your home directory set the  
various java variables like CLASSPATH and such to point to your VTK  
installation.

Of course if you are going to write something that will eventually be  
passed out to others then you will want to explore creating a .app  
package and possibly using the "@executable_path/../PlugIns" as the  
embedded path in the libraries.

Have fun..

Cheers
-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jan 18, 2007, at 11:17 AM, Mike Jackson wrote:

> OK.. found the problem in the build. When compiling against java,  
> somewhere in the link libraries must be "-framework JavaVM"
>
> I manually added that to ${ProjectBinaryDirectory}/CMakeFiles/ 
> vtkRenderingJava.dir/link.txt and reran make and I am at least  
> getting farther now..
>
> As far as putting this somewhere in ccmake I am not sure.. I don't  
> want _ALL_ my libs to link aganst the JavaVM so maybe there is a  
> setting somewhere that says if you are linking against Java then  
> add -framework JavaVM to the list..
>
> Someone from Kitware want to chime in....
>
> Thanks
> -- 
> Mike Jackson   Senior Research Engineer
> Innovative Management & Technology Services
>
>
> On Jan 17, 2007, at 4:59 PM, Kenneth Sloan wrote:
>
>> Current status:
>>
>> Starting with the latest official release (NOT the CVS  
>> repository), I started with an "accept all defaults" build and  
>> slowly changed this to get to this point:
>>
>>
>>
>>                                                     Page 1 of 1
>> BUILD_EXAMPLES                   ON
>> BUILD_SHARED_LIBS                ON
>> CMAKE_BACKWARDS_COMPATIBILITY    2.4
>> CMAKE_BUILD_TYPE
>> CMAKE_INSTALL_PREFIX             /usr/local
>> CMAKE_OSX_ARCHITECTURES          i386
>> CMAKE_OSX_SYSROOT                /Developer/SDKs/MacOSX10.4u.sdk
>> PYTHON_DEBUG_LIBRARY             -framework Python
>> PYTHON_INCLUDE_PATH              /usr/include/python2.3
>> PYTHON_LIBRARY                   /usr/lib/libpython2.3.dylib
>> VTK_DATA_ROOT                    /Users/kennethsloan/kitware/ 
>> VTK-5-0-2/VTKData
>> VTK_USE_CARBON                   OFF
>> VTK_USE_COCOA                    ON
>> VTK_USE_PARALLEL                 OFF
>> VTK_USE_RENDERING                ON
>> VTK_USE_RPATH                    OFF
>> VTK_USE_X                        OFF
>> VTK_WRAP_JAVA                    ON
>> VTK_WRAP_PYTHON                  ON
>> VTK_WRAP_TCL                     ON
>>
>> make
>> ...
>> [ 65%] Building CXX object Rendering/CMakeFiles/ 
>> vtkRenderingJava.dir/vtkCocoaRenderWindowJava.o
>> Linking CXX shared library ../bin/libvtkRenderingJava.dylib
>> ld: Undefined symbols:
>> _JAWT_GetAWT
>> /usr/bin/libtool: internal link edit command failed
>> make[2]: *** [bin/libvtkRenderingJava.5.0.2.dylib] Error 1
>> make[1]: *** [Rendering/CMakeFiles/vtkRenderingJava.dir/all] Error 2
>> make: *** [all] Error 2
>>
>>
>>
>> So, I'm back to square one.  Tonight, I'll try some of the fixes  
>> suggested in previous e-mails, having to do with specifying the  
>> path to the Java AWT library.
>>
>> Now, at least, I have a complete log of what I did to get to this  
>> point, and the ONE change to ccmake's options that broke things.   
>> The build immediately before this one had VTK_WRAP_JAVA  OFF, and  
>> everything else was exactly the same.  That build completed with  
>> no errors.
>>
>> Java itself (jre and jdk) are running just fine (I have a number  
>> of Java programs developed completely on this machine - all  
>> compile and execute as expected).  But, I'm a novice with the Mac  
>> OS X conventions on where things are kept, and even more of a  
>> novice with ccmake and friends (so I need a lot of handholding to  
>> make changes).
>>
>> Thanks to everyone who has helped so far.  I'm back where I  
>> started, but I think I understand the mechanisms just a little bit  
>> better (so I might understand your suggestions) AND we have a  
>> demonstration that things build correctly on this machine with  
>> everything EXCEPT Java - and break when we turn Java on.
>>
>> On the back burner, for the moment, is the question of why the  
>> current CVS version of the source does not compile on my machine.   
>> I'm (personally) not going to care about that for the moment -  
>> except that I don't think the suggestion "try the CVS source" will  
>> be useful.
>>
>> I suspect we now REALLY need someone who knows VTK, Mac OS X, AND  
>> Java.
>>
>> --
>> Kenneth Sloan                                           
>> KennethRSloan at gmail.com
>> Computer and Information Sciences                         
>> +1-205-934-2213
>> University of Alabama at Birmingham              FAX +1-205-934-5473
>> Birmingham, AL 35294-1170                http://www.cis.uab.edu/ 
>> sloan/
>>
>>
>> _______________________________________________
>> 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:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
> _______________________________________________
> 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:
> http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list