How to compile VTK for Java using Microsoft Visual Studio .NET 2003

How to compile VTK for Java using Microsoft Visual Studio .NET 2003

Currently, I’m doing a Java Project that need some 3D image processing so I come across with VTK which is an open source consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. To use VTK in Java, I need to compile VTK for using with Java. I have found only a few website that related with this topic and hardly to get troubleshoot problems so I decided to write the tutorial.

What do you need?

  1. VTK Source and Data.
    In the example, I used VTK Source 4.4.2 and Data 5.0.2. I’ve found that when compile Source 5.0.2 in VS .NET, I got some errors so I recommend as that I use.
  2. CMake Cross Platform Make.
    In the example, I used CMake 2.4.6
  3. Microsoft Visual Studio .NET 2003

Step-By-Step Guide

  1. Extract VTK Source and Data. I extract VTK Source to C:\VTK and VTK Data to C:\VTK\VTKData.
  2. Run CMake to make project for VS .NET 2003
  3. A CMake icon

  4. Specify source code path as C:\VTK and build binaries to C:\VTK\Bin as figure below.
    You can choose place to keep Binaries elsewhere if you want.
  5. CMake's Window

  6. Click Configure. New Window appears to let you choose which compiler you want CMake to build for. Select Visual Studio 7 .NET 2003. Click OK.
  7. Choose Generator

  8. New Window appears to confirm new directory creation. Click OK. Wait few minutes.
  9. Create new directory confirmation

  10. When finished, there will be some attributes show in cache values in red. Change some attributes as figure below. Then Click Configure, again.
    BUILD_SHARED_LIBS = ON.
    VTK_DATA_ROOT = C:\VTK\VTKDAta (Where you extract VTKData).
    VTK_WRAP_JAVA = ON (To make library for Java)
  11. CMake Configuration for Java

  12. When configured done, the color on attributes will change to gray. Now Click OK.
  13. Compiled configuration

  14. When finished, CMake will close itself automatically. Now let see C:\VTK\Bin, where you build Binaries to, you will see solution file (VTK.sln). Double-click it to run Visual Studio.
  15. Solution file was created

  16. Change Solution Configuration to Release to make sure that the compiled libraries can be use on other machine.
  17. Change to Release solution

  18. Then, Click Start (Debug -> Start) or press F5 to compile the project. This step may takes up to 1-2 hours depends on your CPU.
  19. Run VTK's project

  20. There may be new window show about configurations are out of date, just ignore it by select Yes.
  21. Notify out of date configurations

  22. The Compile will finish when the output window show as below.
  23. Compiled Project

  24. If there is a window as below, you can ignore it by Click Cancel.
  25. Specify Debugging

  26. Finish!. Now you get the compiled library files in C:\VTK\Bin\bin\release for DLL files and C:\VTK\Bin\java\vtk for Java Class files.
  27. Libraries folder
    Libraries folder

  28. For DLL libraries in Release folder, you can use by add System path to the folder. My Computer -> Properties -> Advanced -> Environment Variables -> Edit on Path in System Variables. Insert directory where DLL files are.
    Add DLL libraries
  29. For Java libraries in java\vtk\, you can use by compile them to .class file.

7 Comments

  1. Alex April 10, 2008
  2. linglom April 11, 2008
  3. Jose June 1, 2008
  4. Ali May 11, 2009
  5. Ali May 13, 2009
  6. linglom May 14, 2009
  7. Arjun Walmiki August 13, 2013

Leave a Reply