Compiling VTK 9.1.0 in MSYS2/MinGW64 with gcc 8.3.0 and 11.2.0: error in debug mode.

Greetings,

I’m getting this error when compiling VTK 9.1.0 in debug mode (release mode compiles just fine):

CMakeFiles\IOLegacy.dir/objects.a(vtkCompositeDataReader.cxx.obj): In function `vtkCompositeDataReader::ReadCompositeData(vtkOverlappingAMR*)':
D:/W64/VTK-9.1.0/IO/Legacy/vtkCompositeDataReader.cxx:410: undefined reference to `vtkAOSDataArrayTemplate<int>::GetTypedTuple(long long, int*) const'
collect2.exe: error: ld returned 1 exit status

The only difference in configuration with respect to release mode is:

CMAKE_C_FLAGS_DEBUG=-g -O1 -Wa,-mbig-obj
CMAKE_CXX_FLAGS_DEBUG=-g -O1 -Wa,-mbig-obj

This is necessary to compile vtkExprTkFunctionParser.h/.cxx which wraps ExprTk, a header-only library known to define too many symbols.

CMake configuration:
CMakeCache.txt (162.9 KB)

Build log:
LOG_BUILD.TXT (915.7 KB)

Thanks in advance,

Paulo

1 Like

Just upgraded to the latest version of GCC (11.2) for no avail.

SOLUTION: Tweak the VTK header that defines the offending symbol by moving the definition to outside of the class declaration. In the example above, it is the GetTypedTuple() method of the vtkAOSDataArrayTemplate class. This class is defined in vtkAOSDataArrayTemplate.h header. Following the rationale explained here: https://gitlab.kitware.com/vtk/vtk/-/issues/16916 , I changed the original code bellow located inside the definition of the vtkAOSDataArrayTemplate class:

/**
 * Copy the tuple at @a tupleIdx into @a tuple.
 */
void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
{
  const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents;
  std::copy(this->Buffer->GetBuffer() + valueIdx,
    this->Buffer->GetBuffer() + valueIdx + this->NumberOfComponents, tuple);
}
///@}

To:

void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const;

Then add the definition of the offending method to outside:

///@{
  /**
   * Copy the tuple at @a tupleIdx into @a tuple.
   */
  template <class ValueTypeT>
  void vtkAOSDataArrayTemplate<ValueTypeT>::GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
    VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
  {
    const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents;
    std::copy(this->Buffer->GetBuffer() + valueIdx,
      this->Buffer->GetBuffer() + valueIdx + this->NumberOfComponents, tuple);
  }
  ///@}
1 Like