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

Very useful guidelines published at http://www.vtk.org/Wiki/Cocoa_VTK and through the readme file of Sean McBride and Mike Jackson inside the VTK repo are a bit outdated for VTK 6.1. Therefore, if this helps someone, I am sending instructions for installing VTK 6.1 on OSX 10.8 with support for the SimpleCocoaVTK Xcode project.

+8
macos vtk
source share
4 answers

* Install 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 README.rtf in the VTK / Examples / GUI / Cocoa / Sean McBride and Mike Jackson documentation folder.

  • Copy the VTK git repository to the directory of your choice:

    cd / Users / you /

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

    cd VTK

    git verification tags / v 6.1.0

  • create assembly directory

    mkdir VTKBuild

    cd VTKBuild

  • Run VTK cmake script

    • Now you will be inside / Users / you / VTK / VTKBuild, run cmake from here (using the parent directory of the CMake files):

    cmake ..

  • Edit many lines in the newly created CMakeCache.txt (in the current VTKBuild directory). One of my problems was that there was an error if I did not use the full path for CMAKE_INSTALL_PREFIX. Therefore, do not use "/ Users / you /" instead of "~":

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

    BUILD_SHARED_LIBS: BOOL = OFF

    CMAKE_BUILD_TYPE: LINE = debug

    VTK_USE_SYSTEM_ZLIB: BOOL = ON

    CMAKE_OSX_ARCHITECTURES: STRING = i386; x86_64

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

  • Compile the VTK project (this may take more than an hour!):

    to do

  • Copy headers to include directory:

    make installation

  • Now VTK should be fully installed in the VTKBuild directory and ready for use in the Xcode project!

  • Go to your location, go to "Users / you / VTK / Examples / GUI / Cocoa /" and double-click to open SimpleCocoaVTK.xcodeproj in Xcode.

  • In the Xcode menu bar (at the top of the screen) Go to the "Settings" - "Locations->" Source Trees section and use the "+" button to add to the 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

  • Click on the Xcode project and remove all links to vtk 6.0:

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

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

  • Make sure the Xcode file is active. Then in the search box go to / Users / you / VTK / VTKBuild / lib and select all the files starting with "libvtk" and end with "6.1.a". Drag these files into the "vtk-libraries" folder as an Xcode file.

  • In Xcode, go to Product-> Clean

  • Now you can create and run the SimpleCocoaVTK sample project.

+13
source share

I also had to install

VTK_WRAP_PYTHON: BOOL = ON

in CMakeCache.txt

+1
source share

It depends on which user you also use on your computer (computer) and the permissions relevant to that user. I found and replaced the CMakeCache.txt file and changed all / usr / local links to / Users / myusername / Develop / VTKInstall. Thus, everything is at your fingertips, and you do not need to change the rights to things.

When you open the Cocoa example, be sure to set these paths in the settings (for example, “Settings” - “Locations →“ Sources. ”) You will also need to re-import your vtk libraries into the project.

I am running Yosemite with Xcode 6.1.1. Hope this helps someone!

+1
source share

If you get error messages, I like this when trying to build VTK:

@error: garbage collection is no longer supported

make [2]: *** Rendering /OpenGL/CMakeFiles/vtkRenderingOpenGL.dir/vtkCocoaRenderWindowInteractor.mm.o] Error 1

make 1 : *** [[Rendering / OpenGL / CMakeFiles / vtkRenderingOpenGL.dir / all] Error 2

You need to remove the flag in the source CMakeLists.txt file:

@IF(APPLE) SET(VTK_OBJCXX_FLAGS_DEFAULT "-fobjc-gc") SET(VTK_REQUIRED_OBJCXX_FLAGS ${VTK_OBJCXX_FLAGS_DEFAULT} CACHE STRING "Extra flags for Objective-C++ compilation") MARK_AS_ADVANCED(VTK_REQUIRED_OBJCXX_FLAGS) ENDIF(APPLE)@ 

Either push out or delete everything together. Then run cmake again in the empty directory. Check the created CMakeCache.txt file in the assembly directory, if it contains a key such as VTK_REQUIRED_OBJCXX_FLAGS , it should not, then run cmake again in the empty directory.

This bug may be fixed in future versions of VTK.

Source: [SOLVED] Build Qt 5.2.1 + VTK 6.1.0 + CMake 2.8.12.2

0
source share

All Articles