Linking problem with Xcode

Hello everyone,
Since a couple of hours I am struggling to get this C++ example to compile and run properly with Xcode.

What I did to get here is:

  • Install vtk through “brew install vtk”
  • Added the search paths /opt/homebrew/Cellar/vtk/9.2.6_5/lib and /opt/homebrew/Cellar/vtk/9.2.6_5/include/vtk-9.2 to library and header search paths in Build Settings

If I do this, I am getting an error because of undefined symbols:


In this case the code does not compile.
Instead if I add in Build Phases all the dylibs contained in the lib folder, it does compile successfully!

However, this gives a runtime error:

Does anybody know where I’m wrong or have any hints in setting up xcode for vtk c++ examples?

Thank you in advance

It looks like you’re not using CMake to use VTK. There’s a lot of information VTK has CMake manage automatically that needs performed when using VTK as a series of flags to the compiler or settings for the IDE. In this instance, VTK is built against Python, but it lets the executable choose which Python. You’ll need to either link to a Python library/framework or remove the Python-needing library from the linker set if you’re not actually using it.

Thank you, actually I was missing the link to the python framework. Now my code compiles and runs on xcode as expected.

For future reference, for brew installed python, the dylib found in:


has to be linked too, together with the VTK dylibs