# undefined reference to \`PyErr\_Occurred'

**URL:** https://discourse.vtk.org/t/undefined-reference-to-pyerr-occurred/3383
**Category:** Support
**Created:** [May 23, 2020, 6:09pm UTC](https://discourse.vtk.org/t/undefined-reference-to-pyerr-occurred/3383 "2020-05-23T18:09:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jiapei100](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jiapei100/32/157_2.png) [@jiapei100](https://discourse.vtk.org/u/jiapei100)
#### Post date: [May 23, 2020, 6:09pm UTC](https://discourse.vtk.org/t/undefined-reference-to-pyerr-occurred/3383/1 "2020-05-23T18:09:20Z")

</div>

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**.

```auto
...
//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`**.

```auto
[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

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [May 23, 2020, 8:29pm UTC](https://discourse.vtk.org/t/undefined-reference-to-pyerr-occurred/3383/2 "2020-05-23T20:29:29Z")

</div>

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:

```auto
VTK_PYTHON_OPTIONAL_LINK=OFF

```

---

<div class="post-metadata">

### Author: ![jiapei100](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jiapei100/32/157_2.png) [@jiapei100](https://discourse.vtk.org/u/jiapei100)
#### Post date: [May 24, 2020, 6:50pm UTC](https://discourse.vtk.org/t/undefined-reference-to-pyerr-occurred/3383/3 "2020-05-24T18:50:31Z")

</div>

`VTK_PYTHON_OPTIONAL_LINK=OFF` does the trick… Thank you …
