[vtkusers] How to - Installing VTK on Apple OS 10.4.8 Mac Book Pro for the purposes of Cocoa

Ryan Glover prionscientific at gmail.com
Sun Oct 29 11:05:51 EST 2006


Date: October 28, 2006
Author: Ryan Glover prionscientific at gmail.com

This document outlines how to install VTK 5 on an Apple Mac Book Pro
running OS 10.4.8.  Xcode 2.4 is installed.  These instructions have
also been used to install VTK 5 on a Quad G5 running OS  10.4.4 with
Xcode 2.2.

Sean McBride and Mike Jackson of Rogue Research have provided an xcode
project that uses VTK.  It can be downloaded from
http://www.rogue-research.com/vtk/SimpleCocoaVTK.html .  They state in
the document that VTK must already be installed.  This document
explains how to get VTK installed so that the simpleCocoaVTK xcode
project will function.

CMAKE
The first step is to install cmake.  Cmake is cross platform make and
can be downloaded from http://www.cmake.org/HTML/Download.html .  the
version I used most recently was Darwin Universal (Tiger only
installer) cmake-2.4.3-Darwin-universal.dmg.  Download the dmg file
and mount it as you would for any other install.  Run the installer in
the mount and when it is done Cmake will be installed.  This step has
been greatly simplified thanks to the installer.

VTK
Now secure a copy of VTK.  I have had the best experience by
installing VTK from CVS.
We will need a folder to put the vtk build in, I use a folder in my
home directory name Development.  Create a folder where you want vtk
to reside.

Open a terminal window and cd into the folder you just created.  In my
case I issue the command.

cd ~/Development

Now issue the following cvs command

cvs -d :pserver:anonymous at public.kitware.com:/cvsroot/VTK login

You will be asked for a password, it is 'vtk', without the single quotes.

Now issue this cvs command.

cvs -d :pserver:anonymous at public.kitware.com:/cvsroot/VTK checkout VTK

The second command will download VTK into your current folder (the
Development folder).

Everything will be a folder named VTK.  (So my path is ~/Development/VTK).

In ~/Development create a new directory.  I named mine VTKBuild.

mkdir VTKBuild

Move into that folder.

cd VTKBuild

Issue the cmake command.

cmake ../VTK

A lot of code will scroll by.  When it is done you will find a file
named CMakeCache.txt in your VTKBuild folder.  Edit that file in your
favorite text editor. You need to edit it to make VTK build for cocoa
instead of carbon.  Find the following lines in the text file and
change them to look like the following.  (You're turning offs to ons
and vice versa)

VTK_USE_CARBON:BOOL=OFF
VTK_USE_COCOA:BOOL=ON

Save the file.

Make sure you are in ~/Development/VTKBuild and issue the command

cmake ../VTK

again.  When it is complete, do another one for good measure since
Drew McCormick seems to think it's good practise (and it only takes a
second).

In ~/Development/VTKBuild issue the make command.

make

VTK is now being built and a lot of material will scroll by the
screen.  Hopefully there will be no errors.  On my virgin mac book pro
with xcode 2.4 installed it all worked the first time.
When the process is complete create a new folder using the terminal.
I issued the command
sudo mkdir /usr/local/include/vtk-5.1

You may need to create /usr/local/include first, depending on your
system.  The sudo is required because the directory /usr/local is
protected.

Open your favorite text editor and create a new document.  You are
going to create a new shell script named copyVTK.sh.  Put the
following into the new shell script.

#!/bin/sh
for X in Common Filtering GenericFiltering Graphics Hybrid Imaging IO
Parallel Rendering Utilities VolumeRendering Widgets Wrapping
do
	cp /Users/rglover/Development/VTK/${X}/*.h /usr/local/include/vtk-5.1
done
cp /Users/rglover/Development/VTK/*.h /usr/local/include/vtk-5.1

Notice that there is an rglover in the cp lines.  This will be
different on your machine, so change it accordingly.

Save the file to your VTKBuild directory.

The purpose of this shell script is to copy all the .h header files
for vtk into a single directory, the /usr/local/include/vtk-5.1
directory.  We do this because the simpleCocoaVTK xcode project needs
to have all the headers in one folder and installing VTK spreads the
headers in a number of different directories.  This script gathers
them all up and puts them into one folder.  (Just copies though, the
originals are still in the right place).

In the terminal change the shell script to be executable.  Make sure
you are in ~/Development/VTKBuild

chmod 777 copyVTK.sh

Now run the copyVTK.sh script.  Since we are copying into protected
directories we need to issue a sudo command.

sudo ./copyVTK.sh

The script will run and all the files will be copied into the
/usr/local/include/VTK-5.1 folder.

SIMPLE COCOA VTK
To make Xcode aware of VTK we need to add two source trees, as
outlined in the Rogue Research page.

Open the simpleCocoaVTK project in xcode.  Then go to xcode ->
preferences and look for the source tree icon along the top bar.  In
my xcode it is the third icon from the right and looks like a traffic
sign.  Click the icon and a table display will come up.  Click the +
icon twice and add two rows to the table.

For the first row, set the setting name and display name to 'vtk-lib'
(without the single quotes) and set the path to
'/Users/rglover/Development/VTKBuild/bin' (without the single quotes).
 Notice I have my username in there (rglover), replace it with your
own.

For the second row, set the setting name and display name to
'vtk-include' (without the single quotes) and set the path to
'/usr/local/include/VTK-5.1' (without the single quotes).
Case is important here so make sure it is correct.

With the simpleCocoaVTK xcode project open do a 'clean all' by
clicking on the hammer build icon and selecting the double broom clean
all icon.

A final point, make sure zero link is off.  To check this click the
targets icon (looks like a bulls eye) in the left hand menu.  Drop
down the bulls eye until you see the SimpleCocoaVTK target (the
standard A icon made of pencil/pen/ruler).  Click SimpleCocoaVTK to
select it and hit the info button (blue i icon in the top menu).
Click the Build tab and make sure that the configuration drop down
says 'All Configurations' and the collection drop down says 'All
Settings'.
In the search box type 'zerolink'.  The list will shorten to a
manageable size and you will see zero link there.  Click the checkbox
button until it is empty (not a checkmark or a negative sign, just
empty).

Close information and 'clean all' again.

Now build.

Fingers crossed, you should see the app build with no errors and begin to run.

Good luck.
Ryan Glover



More information about the vtkusers mailing list