Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install VTK 6.1 for OSX 10.8 with Cocoa/XCode support?

Tags:

macos

vtk

The extremely helpful guidelines posted at http://www.vtk.org/Wiki/Cocoa_VTK and via the readme file by Sean McBride and Mike Jackson inside the VTK repo were slightly out of date for VTK 6.1. So in case this helps anybody, I'm posting instructions for installing VTK 6.1 on OSX 10.8 with support for the SimpleCocoaVTK Xcode project.

like image 240
Angus Forbes Avatar asked Jun 26 '13 19:06

Angus Forbes


2 Answers

* Installing VTK 6.1 for OSX 10.8 with Cocoa support *

These instructions slightly modify Ryan Glover's instructions at http://www.vtk.org/Wiki/Cocoa_VTK and the README.rtf in the VTK/Examples/GUI/Cocoa/Documentation folder by Sean McBride and Mike Jackson.

  1. Clone the VTK git repo into a directory of your choice:

    cd /Users/you/

    git clone https://github.com/Kitware/VTK.git

    cd VTK

    git checkout tags/v6.1.0

  2. make a build directory

    mkdir VTKBuild

    cd VTKBuild

  3. Run the VTK cmake script

    • You will now be inside /Users/you/VTK/VTKBuild, run cmake from here (using the parent directory's CMake files):

    cmake ..

  4. Edit lots of lines in the newly generated CMakeCache.txt (in the current VTKBuild directory). One issue I had was that there were error if I didn't use a full path for the CMAKE_INSTALL_PREFIX. So make sure to use "/Users/you/" instead of "~":

    CMAKE_INSTALL_PREFIX:PATH=/Users/you/VTK/VTKBuild

    BUILD_SHARED_LIBS:BOOL=OFF

    CMAKE_BUILD_TYPE:STRING=Debug

    VTK_USE_SYSTEM_ZLIB:BOOL=ON

    CMAKE_OSX_ARCHITECTURES:STRING=i386;x86_64

    CMAKE_OSX_SYSROOT:STRING=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk

  5. Compile the VTK project (this might take over an hour to run!):

    make

  6. Copy headers to an include directory:

    make install

  7. VTK should now be completely installed in the VTKBuild directory and ready to use in an XCode project!

  8. Go to your finder, navigate to Users/you/VTK/Examples/GUI/Cocoa/ and double click to open SimpleCocoaVTK.xcodeproj in XCode.

  9. In the XCode menubar (at the top of the screen) Go to Preferences->Locations->Source Trees and use the + button to add in two source trees:

    vtk-debug-include vtk-debug-include Users/you/VTK/VTKBuild/include/vtk-6.1

    vtk-debug-lib vtk-debug-lib Users/you/VTK/VTKBuild/lib

  10. Click on the XCode project and delete all the references to vtk 6.0:

    • In the project view, select Targets->SimpleCocoaVTK and then press "Build Phases" and then open the "Link Binary With Libraries". Delete all the files that begin with "libvtk" and end with "6.0.a"

    • In the file view of the SimpleCocoaVTK project, hightlight and delete all the files in the vtk-libraries folder.

  11. Make sure the XCode file view is active. Then in the finder, navigate to /Users/you/VTK/VTKBuild/lib, and select all the files that begin with "libvtk" and end with "6.1.a". Drag these files into the folder "vtk-libraries" in the XCode file view.

  12. In XCode, do a Product->Clean

  13. You can now build and run the sample SimpleCocoaVTK project.

like image 108
2 revs, 2 users 98% Avatar answered Sep 22 '22 06:09

2 revs, 2 users 98%


I also had to set

VTK_WRAP_PYTHON:BOOL=ON

in CMakeCache.txt

like image 30
Tom Ryan Avatar answered Sep 22 '22 06:09

Tom Ryan