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

**URL:** https://discourse.vtk.org/t/compiling-vtk-9-1-0-in-msys2-mingw64-with-gcc-8-3-0-and-11-2-0-error-in-debug-mode/7940
**Category:** Support
**Created:** [February 28, 2022, 9:53pm UTC](https://discourse.vtk.org/t/compiling-vtk-9-1-0-in-msys2-mingw64-with-gcc-8-3-0-and-11-2-0-error-in-debug-mode/7940 "2022-02-28T21:53:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 28, 2022, 9:53pm UTC](https://discourse.vtk.org/t/compiling-vtk-9-1-0-in-msys2-mingw64-with-gcc-8-3-0-and-11-2-0-error-in-debug-mode/7940/1 "2022-02-28T21:53:41Z")

</div>

Greetings,

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

```bash
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:

```auto
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](https://discourse.vtk.org/uploads/short-url/1wjo3tNKSkmFOu9272OEwbpqbH6.txt) (162.9 KB)

Build log:  
[LOG\_BUILD.TXT](https://discourse.vtk.org/uploads/short-url/4yycYUgceCkcM2fSf98Rv68F7lN.TXT) (915.7 KB)

Thanks in advance,

Paulo

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 2, 2022, 1:17am UTC](https://discourse.vtk.org/t/compiling-vtk-9-1-0-in-msys2-mingw64-with-gcc-8-3-0-and-11-2-0-error-in-debug-mode/7940/2 "2022-03-02T01:17:49Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 2, 2022, 2:13pm UTC](https://discourse.vtk.org/t/compiling-vtk-9-1-0-in-msys2-mingw64-with-gcc-8-3-0-and-11-2-0-error-in-debug-mode/7940/3 "2022-03-02T14:13:24Z")

</div>

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](https://gitlab.kitware.com/vtk/vtk/-/issues/16916) , I changed the original code bellow located inside the definition of the vtkAOSDataArrayTemplate class:

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

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

```

Then add the definition of the offending method to outside:

```cpp
///@{
  /**
   * 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);
  }
  ///@}

```
