link error:libvtkCommonDataModel-9.3.so.9.3: undefined reference to `vtkpugixml::xml_attribute_iterator::operator!

My configuration : ubuntu 22.04,linking stage gives this error:

[ 98%] Built target WrapJava
[ 99%] Built target PythonInterpreter
[ 99%] Linking CXX executable ../../bin/vtkProbeOpenGLVersion-9.3
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to `vtkpugixml::xml_attribute_iterator::operator!=(vtkpugixml::xml_attribute_iterator const&) const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to `vtkpugixml::xml_parse_result::operator bool() const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to `vtkpugixml::xml_node::child(char const*) const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to `vtkpugixml::xml_attribute::operator!() const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to `vtkpugixml::xml_node::append_copy(vtkpugixml::xml_node const&)'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to `vtkpugixml::xml_attribute::as_int(int) const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to `vtkpugixml::xml_document::~xml_document()'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to `vtkpugixml::xml_node::xml_node()'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to `vtkpugixml::xml_node::append_attribute(char const*)'
/...

As you can see in attached image,the libvtkpugixml got built:
Selection_872

How to fix this issue?

Hello,

Can you, please, try to share the linker command for one of the offending libraries (e.g. vtkCommonDataModel.so) ? It’s something starting with g++ -Wl .... To enable a more verbose output to get the linker commands printed to your shell (I suppose you’re using GCC’s make), please, refer to this: Using CMake with GNU Make: How can I see the exact commands? - Stack Overflow .

best,

PC

@Paulo_Carvalho Thanks for replying,something like this:

[ 99%] Linking CXX executable ../../bin/vtkProbeOpenGLVersion-9.3 cd /home/alex/workspace/VTK/Debug/Rendering/OpenGL2 && /usr/bin/cmake -E cmake_link_script CMakeFiles/vtkProbeOpenGLVersion.dir/link.txt --verbose=1 /usr/bin/c++ -g -Wl,-lc -Wl,-lc CMakeFiles/vtkProbeOpenGLVersion.dir/vtkProbeOpenGLVersion.cxx.o -o ../../bin/vtkProbeOpenGLVersion-9.3 -Wl,-rpath,"\$ORIGIN/../lib/x86_64-linux-gnu:" ../../lib/x86_64-linux-gnu/libvtkRenderingOpenGL2-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkRenderingHyperTreeGrid-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkImagingCore-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkRenderingUI-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkRenderingCore-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkFiltersGeneral-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkFiltersCore-9.3.so.9.3 /usr/lib/x86_64-linux-gnu/libX11.so ../../lib/x86_64-linux-gnu/libvtkglew-9.3.so.9.3 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libX11.so ../../lib/x86_64-linux-gnu/libvtkCommonExecutionModel-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkCommonTransforms-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkCommonMisc-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkCommonMath-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkkissfft-9.3.so.9.3 ../../lib/x86_64-linux-gnu/libvtkCommonCore-9.3.so.9.3 /usr/lib/gcc/x86_64-linux-gnu/11/libgomp.so /usr/lib/x86_64-linux-gnu/libpthread.a ../../lib/x86_64-linux-gnu/libvtksys-9.3.so.9.3 -ldl -Wl,-rpath-link,/home/alex/workspace/VTK/Debug/lib/x86_64-linux-gnu /usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to vtkpugixml::xml_attribute_iterator::operator!=(vtkpugixml::xml_attribute_iterator const&) const’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to vtkpugixml::xml_parse_result::operator bool() const' /usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to vtkpugixml::xml_node::child(char const*) const’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to vtkpugixml::xml_attribute::operator!() const' /usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to vtkpugixml::xml_node::append_copy(vtkpugixml::xml_node const&)’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to vtkpugixml::xml_attribute::as_int(int) const' /usr/bin/ld: ../../lib/x86_64-linux-gnu/libvtkIOImage-9.3.so.9.3: undefined reference to vtkpugixml::xml_document::~xml_document()’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/libvtkCommonDataModel-9.3.so.9.3: undefined reference to vtkpugixml::xml_node::xml_node()'

add after:
ldd libvtkCommonDataModel-9.3.so

I got:

	linux-vdso.so.1 (0x00007ffe35bad000)
	/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x0000775063c00000)
	libvtkCommonTransforms-9.3.so.1 (0x00007750649ce000)
	libvtkCommonMisc-9.3.so.1 (0x0000775063400000)
	libvtkCommonSystem-9.3.so.1 (0x000077506499c000)
	libvtkCommonMath-9.3.so.1 (0x0000775064962000)
	libvtkCommonCore-9.3.so.1 (0x0000775060c00000)
	libvtksys-9.3.so.1 (0x0000775063f93000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000775060800000)
	libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x0000775063eac000)
	libgcc_s.so.1 => /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000077506493c000)
	libc.so.6 => /usr/lib/x86_64-linux-gnu/libc.so.6 (0x0000775060400000)
	libdl.so.2 => /usr/lib/x86_64-linux-gnu/libdl.so.2 (0x0000775064937000)
	libpthread.so.0 => /usr/lib/x86_64-linux-gnu/libpthread.so.0 (0x0000775064932000)
	libvtkkissfft-9.3.so.1 (0x0000775064928000)
	/lib64/ld-linux-x86-64.so.2 (0x0000775064a1f000)
	libvtkloguru-9.3.so.1 (0x000077506490a000)
	libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x0000775063e58000)

Seems like that vtkCommonDataModel won’t use pugixml

Hello,

If you don’t need pugixml, I recommend disabling it in CMake configuration:

If you need it, then CMake is not adding pugixml to the list of libraries in the linker commands, according to the output posted by you. If so, I’d report an issue here: https://gitlab.kitware.com/vtk/vtk/-/issues.

regards,

PC

Thx,if disable it,I got:

CMake Error at CMake/vtkModule.cmake:1075 (message):
  The VTK::CommonDataModel module (enabled because all VTK builds require
  VTK::CommonDataModel) requires the disabled module VTK::pugixml (disabled
  via a `NO` setting (via `VTK_MODULE_ENABLE_VTK_pugixml`)).
Call Stack (most recent call first):
  CMakeLists.txt:402 (vtk_module_scan)

Well… that adds to the confusion… Then, I have to ask to myself: why is there an option to disable something that is a requirement to a core module?

I believe you’re left for reporting an issue.

What version of GCC do you have?

It would also be useful if you post the first error encountered during the build. It is possible that something wrong went unnoticed before the linker error. Please, go to the build directory, clean the build (e.g. make clean) and rebuild redirecting the outputs (both regular and errors) to a file: make ... > log.txt 2>&1. Please, share the build log here (make sure to remove any sensitive information such as passwords, license keys, etc. that may appear in the build messages).

g++ 11

That’s a C++ standard. I asked for the compiler version: g++ --version.