Fix linking libvtkWrapping with Python wrapping and kits enabled on Mac
On Mac, the libvtkWrapping-8.1.1 library fails to link to libpython when configuring with VTK_WRAP_PYTHON and VTK_ENABLE_KITS enabled.
This commit ensures that the library links to libpython.
This fixes the following error:
FAILED: lib/libvtkWrapping-8.1.1.dylib
Undefined symbols for architecture x86_64:
"_PyCallable_Check", referenced from:
vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
"_PyErr_Clear", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PyErr_Fetch", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PyImport_ImportModule", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PyInt_AsLong", referenced from:
vtkPythonAlgorithm::CheckResult(char const*, vtkSmartPyObject const&) in vtkPythonAlgorithm.cxx.o
"_PyInt_FromLong", referenced from:
vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
"_PyObject_Call", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
"_PyObject_GetAttrString", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
"_PyObject_Str", referenced from:
vtkPythonAlgorithm::PrintSelf(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, vtkIndent) in vtkPythonAlgorithm.cxx.o
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PySequence_Fast", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PySequence_Size", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PyString_AsString", referenced from:
vtkPythonAlgorithm::PrintSelf(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, vtkIndent) in vtkPythonAlgorithm.cxx.o
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
"_PyTuple_New", referenced from:
GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
Merge request reports
Activity
added 42 commits
-
fcba8a82...94ba4ab1 - 41 commits from branch
vtk:master
- 65502d52 - Fix linking libvtkWrapping with Python wrapping and kits enabled on Mac
-
fcba8a82...94ba4ab1 - 41 commits from branch
This is related to the changes from !1713 (merged).
+1 This looks good to me, and was necessary in order for me to build kits on OS X without link errors.
@brad.king do you see any potential issues with this change?
@iMichka please take a look.
Linking to python should not be required. I suspect a change like this one need to be done: d0aed867
In other word, since at run time, python symbols can be exported by either the python library or the python executable, we should not have to explicitly link the python library.
I think @jcfr's suggestion is likely the best path forward. At runtime the symbols will be available. We just need to drop
--no-undefined
to avoid the complaint at link time.This issue is specifically for MacOS/clang so
--no-undefined
doesn't apply, does it? The build never used--no-undefined
or any equivalent.Edited by David GobbiOn MacOSX, flag like
-undefined dynamic_lookup
should be used and this is the role ofvtk_target_link_libraries_with_dynamic_lookup
.It looks like (1) something prevent the test
_vtkCheckUndefinedSymbolsAllowed
from working as expected on MacOSx or (2)vtk_target_link_libraries_with_dynamic_lookup
is not used in some location.Either way, now I am done adding support for Linux and Windows python wheels to https://github.com/jcfr/VTKPythonPackage, I will work on MAcOSX and I will tackle this.
added 56 commits
-
65502d52...f3c3f8d4 - 55 commits from branch
vtk:master
- de1a9397 - Fix linking libvtkWrapping with Python wrapping and kits enabled on Mac
-
65502d52...f3c3f8d4 - 55 commits from branch
@dgobbi Agreed.
Ideally should have a way to teach the linker to allow dynamic lookup of only a subset of symbols (python symbols in that case). That way, the linking would file if symbols different from the python ones are missing.
In the mean time
Cc: @thewtex