[vtkusers] Problem with building VTK 5.0.3 with Python/Tk on Mac OSX 10.4.1

Thomas, JMH (Jens) j.m.h.thomas at dl.ac.uk
Thu Dec 13 05:08:43 EST 2007


I'm largely answering my own question here in case what I've found is of use to anyone else, but also in case what I've discovered qualifies as a bug.

It seems that the default build for VTK on Mac OSX has been changed from Carbon to Cocoa. However (from what I can make out from the root CMakeLists.txt file and the file vtkTkRenderWidget.cxx),  it looks like the Tk functionality is only available with Carbon or X.

There is a block of code in the root CMakeLists.txt that only turns on VTK_USE_TK if Cocoa isn't being used and VTK_DISABLE_TK_INIT isn't set. As I had turned on the Python and Tcl wrappers but was using the default Cocoa option, the Tk stuff wasn't being built, triggering the error I was seeing.

I've reverted to the Carbon build and have now managed to get my universal build working.

The build wasn't completely trouble-free though, as there were still problems with the linking of the files:


as the tcl/tk libraries weren't included on the link line.

Best wishes,


Hi Sean,

Thanks for getting back to me.

 >Also, do you really mean 10.4.1?  Or do you mean 10.4.11 or 10.5.1?  In
 >any case, which version of Xcode do you have?

Sorry - that was a typo, it's OSX 10.4.11 with Xcode 2.5

 >>I've attached my CmakeCache.txt and have included some additional
 >>information below in case it is of any use.

 >1200 lines of text is a lot... :)  What settings did you change from
 >their default?



 >If you are on 10.5, I suggest CVS CMake also.

I've redone the build with CVS versions of both VTK and CMake. The build 
fails twice as -ltcl is missing from the link stage for 
libvtkCommonTCL.5.1.0.dylib and the file vtk right at the end of the build.

I was able to fix the former by editing the file 
Common/CMakeFiles/vtkCommonTCL.dir/link.txt to add -ltcl and the latter 
by manually executing the link for vtk and appending -ltcl.

This allows the build to run to completion.

However, if I install the python files (using setup.py) and then try and 
run the file:


It fails with the error:

  File "./vtkTkRenderWidget.py", line 466, in <module>
  File "./vtkTkRenderWidget.py", line 443, in vtkRenderWidgetConeExample
    pane = vtkTkRenderWidget(root,width=300,height=300)
  File "./vtkTkRenderWidget.py", line 81, in __init__
line 67, in vtkLoadPythonTkWidgets
    interp.call('load', filename)
_tkinter.TclError: image not found
NSCreateObjectFileImageFromFile() error: not a Mach-O MH_BUNDLE file

It appears it's trying to load the file 
libvtkRenderingPythonTkWidgets.dylib, but this file hasn't been built 
(which I think is because the Cmake variable VTK_USE_TK hasn't been set, 
even though the Tcl and Tk libraries were found during the configure).

Is there an easy way to fix this?

 >Lastly, there are some Mac dashboards that enable TCL, you may want to
 >look at their settings.

I'm not very familiar with dashboard, so it's quite possible I missed 
something, but've looked at


and couldn't find any that had the python and tcl wrapping turned on.

Best wishes,


Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

Jens Thomas,                email:  j.m.h.thomas at dl.ac.uk
STFC Daresbury Lab,         tel:    +44-1925-603849
Warrington,                 fax:    +44-1925-603634
WA4 4AD,  UK.               http:   http://www.cse.scitech.ac.uk

More information about the vtkusers mailing list