undefined reference to `PyErr_Occurred'

Hi, I’m trying to build VTK again, but it seems the settings are a little different from before. Anyway, RenderingGL2PSOpenGL2 seems to be set as DEFAULT, which seems to be YES.

...
//Enable the VTK::RenderingGL2PSOpenGL2 module. 
VTK_MODULE_ENABLE_VTK_RenderingGL2PSOpenGL2:STRING=DEFAULT

//Enable the VTK::RenderingImage module. 
VTK_MODULE_ENABLE_VTK_RenderingImage:STRING=DEFAULT
...

The built result gave me a lot of undefined referent to PyXXXXXXXX.

[ 55%] Linking CXX shared module lib/python3.6/site-packages/vtkmodules/vtkRenderingGL2PSOpenGL2.cpython-36m-x86_64-linux-gnu.so
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC   -O3 -DNDEBUG  -Wl,-lc  -Wl,-lc   -shared  -o lib/python3.6/site-packages/vtkmodules/vtkRenderingGL2PSOpenGL2.cpython-36m-x86_64-linux-gnu.so CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2Python/vtkOpenGLGL2PSHelperImplPython.cxx.o CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2Python/vtkRenderingGL2PSOpenGL2ModulePython.cxx.o CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2PythonPython/vtkRenderingGL2PSOpenGL2PythonInit.cxx.o CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2PythonPython/vtkRenderingGL2PSOpenGL2PythonInitImpl.cxx.o  -Wl,-rpath,"\$ORIGIN/../../../:/usr/local/lib:" lib/libvtkRenderingGL2PSOpenGL2-9.0.so.8.2.0 lib/libvtkWrappingPythonCore-9.0.so.8.2.0 lib/libvtkRenderingOpenGL2-9.0.so.8.2.0 lib/libvtkRenderingUI-9.0.so.8.2.0 /usr/lib/x86_64-linux-gnu/libX11.so lib/libvtkglew-9.0.so.8.2.0 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/local/lib/libSDL2-2.0.so.0.10.0 -lm /usr/lib/x86_64-linux-gnu/libsndio.so -ldbus-1 -Wl,--no-undefined -pthread /usr/lib/x86_64-linux-gnu/libX11.so lib/libvtkRenderingCore-9.0.so.8.2.0 lib/libvtkFiltersCore-9.0.so.8.2.0 lib/libvtkCommonExecutionModel-9.0.so.8.2.0 lib/libvtkCommonDataModel-9.0.so.8.2.0 lib/libvtkCommonTransforms-9.0.so.8.2.0 lib/libvtkCommonMisc-9.0.so.8.2.0 lib/libvtkCommonMath-9.0.so.8.2.0 lib/libvtkCommonCore-9.0.so.8.2.0 -lpthread /usr/local/lib/libmemkind.so lib/libvtksys-9.0.so.8.2.0 -ldl -Wl,-rpath-link,/usr/local/lib:....../vtk/build_18.04/lib 
CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2Python/vtkOpenGLGL2PSHelperImplPython.cxx.o: In function `PyvtkOpenGLGL2PSHelperImpl_SafeDownCast(_object*, _object*)':
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0xe2): undefined reference to `PyErr_Occurred'
CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2Python/vtkOpenGLGL2PSHelperImplPython.cxx.o: In function `PyvtkOpenGLGL2PSHelperImpl_IsTypeOf(_object*, _object*)':
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0x1b7): undefined reference to `PyErr_Occurred'
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0x1c4): undefined reference to `PyLong_FromLong'
CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2Python/vtkOpenGLGL2PSHelperImplPython.cxx.o: In function `PyvtkOpenGLGL2PSHelperImpl_GetNumberOfGenerationsFromBaseType(_object*, _object*)':
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0x2d5): undefined reference to `PyErr_Occurred'
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0x2e2): undefined reference to `PyLong_FromLongLong'
CMakeFiles/vtkRenderingGL2PSOpenGL2Python.dir/CMakeFiles/vtkRenderingGL2PSOpenGL2Python/vtkOpenGLGL2PSHelperImplPython.cxx.o: In function `PyvtkOpenGLGL2PSHelperImpl_GetNumberOfGenerationsFromBase(_object*, _object*)':
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0x455): undefined reference to `PyErr_Occurred'
vtkOpenGLGL2PSHelperImplPython.cxx:(.text+0x462): undefined reference to `PyLong_FromLongLong'

Can anybody give me a hand??

Thank you
Pei

Your libraries (e.g. libvtksys-9.0.so.8.2.0) have a combination of ‘9.0’ and ‘8.2’ in their name, so I’m guessing that you didn’t erase the contents of your build directory before trying to re-build.

There is also a -Wl,--no-undefined on your link line, which is definitely not present on my link line. Do you know where this might have come from? It is the reason for the undefined reference errors.

Edit: if the problem persists after a clean build, add this to your cmake configuration:

VTK_PYTHON_OPTIONAL_LINK=OFF
1 Like

VTK_PYTHON_OPTIONAL_LINK=OFF does the trick… Thank you …