link 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/ undefined reference to `vtkpugixml::xml_attribute_iterator::operator!=(vtkpugixml::xml_attribute_iterator const&) const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_parse_result::operator bool() const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_node::child(char const*) const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_attribute::operator!() const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_node::append_copy(vtkpugixml::xml_node const&)'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_attribute::as_int(int) const'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_document::~xml_document()'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_node::xml_node()'
/usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to `vtkpugixml::xml_node::append_attribute(char const*)'

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

How to fix this issue?


Can you, please, try to share the linker command for one of the offending libraries (e.g. ? 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 .



@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/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ ../../lib/x86_64-linux-gnu/ /usr/lib/gcc/x86_64-linux-gnu/11/ /usr/lib/x86_64-linux-gnu/libpthread.a ../../lib/x86_64-linux-gnu/ -ldl -Wl,-rpath-link,/home/alex/workspace/VTK/Debug/lib/x86_64-linux-gnu /usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_attribute_iterator::operator!=(vtkpugixml::xml_attribute_iterator const&) const’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_parse_result::operator bool() const' /usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_node::child(char const*) const’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_attribute::operator!() const' /usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_node::append_copy(vtkpugixml::xml_node const&)’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_attribute::as_int(int) const' /usr/bin/ld: ../../lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_document::~xml_document()’
/usr/bin/ld: …/…/lib/x86_64-linux-gnu/ undefined reference to vtkpugixml::xml_node::xml_node()'

add after:

I got: (0x00007ffe35bad000)
	/usr/lib/x86_64-linux-gnu/ (0x0000775063c00000) (0x00007750649ce000) (0x0000775063400000) (0x000077506499c000) (0x0000775064962000) (0x0000775060c00000) (0x0000775063f93000) => /usr/lib/x86_64-linux-gnu/ (0x0000775060800000) => /usr/lib/x86_64-linux-gnu/ (0x0000775063eac000) => /usr/lib/x86_64-linux-gnu/ (0x000077506493c000) => /usr/lib/x86_64-linux-gnu/ (0x0000775060400000) => /usr/lib/x86_64-linux-gnu/ (0x0000775064937000) => /usr/lib/x86_64-linux-gnu/ (0x0000775064932000) (0x0000775064928000)
	/lib64/ (0x0000775064a1f000) (0x000077506490a000) => /usr/lib/x86_64-linux-gnu/ (0x0000775063e58000)

Seems like that vtkCommonDataModel won’t use pugixml


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:



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.