# Compile vtk-9.1 with mingw-Error

**URL:** https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464
**Category:** Support
**Created:** [December 22, 2021, 7:32am UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464 "2021-12-22T07:32:35Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rockydut](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rockydut/32/4261_2.png) [@rockydut](https://discourse.vtk.org/u/rockydut)
#### Post date: [December 22, 2021, 7:32am UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/1 "2021-12-22T07:32:35Z")

</div>

Dear all. When I compile vtk-9.1 with mingw, it shows the following errors. How to fix this error?  
When I delete the TestAngularPeriodicDataArray.cxx in the compile source, it can compile correctly, but my program shows: undefined reference to `vtkAOSDataArrayTemplate<long long>::GetValue(int) const' in function `vtkCellArray::VisitState::GetBeginOffset(int) const’:  
undefined reference to `vtkAOSDataArrayTemplate::GetValue(int) const’.

[99%] Building CXX object Common/DataModel/Testing/Cxx/CMakeFiles/vtkCommonDataModelCxxTests.dir/TestAngularPeriodicDataArray.cxx.obj  
[99%] Linking CXX executable …\bin\vtkCommonDataModelCxxTests.exe  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonDataModelCxxTests.dir/objects.a(TestAngularPeriodicDataArray.cxx.obj): in function `vtkPeriodicDataArray<float>::GetTypedTuple(int, float*) const': F:/Packages/VTK/VTK/Common/DataModel/vtkPeriodicDataArray.txx:421: undefined reference to `vtkAOSDataArrayTemplate::GetTypedTuple(int, float\*) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonDataModelCxxTests.dir/objects.a(TestAngularPeriodicDataArray.cxx.obj): in function `vtkPeriodicDataArray<double>::GetTypedTuple(int, double*) const': F:/Packages/VTK/VTK/Common/DataModel/vtkPeriodicDataArray.txx:421: undefined reference to `vtkAOSDataArrayTemplate::GetTypedTuple(int, double\*) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: F:/Packages/VTK/VTK/Common/DataModel/vtkPeriodicDataArray.txx:421: undefined reference to `vtkAOSDataArrayTemplate::GetTypedTuple(int, double\*) const’  
collect2.exe: error: ld returned 1 exit status  
mingw32-make[2]: \*\*\* [Common\DataModel\Testing\Cxx\CMakeFiles\vtkCommonDataModelCxxTests.dir\build.make:1947: bin/vtkCommonDataModelCxxTests.exe] Error 1  
mingw32-make[1]: \*\*\* [CMakeFiles\Makefile2:39153: Common/DataModel/Testing/Cxx/CMakeFiles/vtkCommonDataModelCxxTests.dir/all] Error 2  
mingw32-make: \*\*\* [Makefile:145: all] Error 2

---

<div class="post-metadata">

### Author: ![rockydut](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rockydut/32/4261_2.png) [@rockydut](https://discourse.vtk.org/u/rockydut)
#### Post date: [December 22, 2021, 7:37am UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/2 "2021-12-22T07:37:52Z")

</div>

My program shows the following error when delete TestAngularPeriodicDataArray.cxx during the compile of vtk-9.1

 ![2~6T}S)IHA2KYBXIGD~`_$D](https://discourse.vtk.org/uploads/default/original/2X/7/7e989ea75b3912bb38f2b2b242e55567cb773f98.png)

---

<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: [December 23, 2021, 12:08pm UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/3 "2021-12-23T12:08:31Z")

</div>

Hi,

Why are you deleting that file? If you delete `.cxx`'s you will likely have undefined symbol errors like that during linking time. You know, the linker gets the `.obj`s and libraries to make an executable. If you delete a `.cxx` certainly an `.obj` will be missing and it won’t be possible to make a complete executable, hence the undefined symbols errors. If you don’t want to build the tests, simply disable them while configuring the build in CMake: `cmake (...) -DVTK_BUILD_TESTING=NO (...)`.

regards,

Paulo

---

<div class="post-metadata">

### Author: ![rockydut](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rockydut/32/4261_2.png) [@rockydut](https://discourse.vtk.org/u/rockydut)
#### Post date: [January 17, 2022, 6:22am UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/4 "2022-01-17T06:22:32Z")

</div>

When I compile vtk-9.1.0 by mingw64  
When I compile without selecting the testing module, it compile correct.  
However, when I compile with testing, it shows the following errors.  
Who can tell me how to fix this error.

D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x175fc7): undefined reference to `vtkSOADataArrayTemplate<int>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x176507): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17684d): undefined reference to `vtkSOADataArrayTemplate<int>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x176c7a): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x176d36): undefined reference to `vtkSOADataArrayTemplate<int>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x1771cf): more undefined references to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’ follow  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17bc8f): undefined reference to `vtkSOADataArrayTemplate<double>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17bd4f): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17c1bf): undefined reference to `vtkSOADataArrayTemplate<double>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17c27f): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17c4ea): undefined reference to `vtkSOADataArrayTemplate<double>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x17c8ff): more undefined references to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’ follow  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x182066): undefined reference to `vtkSOADataArrayTemplate<float>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x182216): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x182592): undefined reference to `vtkSOADataArrayTemplate<float>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x18264e): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x182faf): undefined reference to `vtkSOADataArrayTemplate<float>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayTupleRange.cxx.obj):TestDataArrayTupleRange.cxx:(.text+0x183037): more undefined references to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’ follow  
D:/Msys64/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/11.2.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayValueRange.cxx.obj):TestDataArrayValueRange.cxx:(.text+0xe4350): undefined reference to `vtkSOADataArrayTemplate<int>::GetTypedComponent(int, int) const' D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\vtkCommonCoreCxxTests.dir/objects.a(TestDataArrayValueRange.cxx.obj):TestDataArrayValueRange.cxx:(.text+0xe4c18): undefined reference to `vtkSOADataArrayTemplate::GetTypedComponent(int, int) const’  
[37%] Built target vtkCommonMiscPython  
[37%] Built target IOCore  
[40%] Built target vtkCommonCorePython  
[40%] Built target AcceleratorsVTKmCore  
[40%] Built target vtkRenderingFreeType-hierarchy  
collect2.exe: error: ld returned 1 exit status  
mingw32-make[2]: \*\*\* [Common\Core\Testing\Cxx\CMakeFiles\vtkCommonCoreCxxTests.dir\build.make:1215: bin/vtkCommonCoreCxxTests.exe] Error 1  
mingw32-make[1]: \*\*\* [CMakeFiles\Makefile2:32852: Common/Core/Testing/Cxx/CMakeFiles/vtkCommonCoreCxxTests.dir/all] Error 2

---

<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: [January 17, 2022, 4:44pm UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/5 "2022-01-17T16:44:23Z")

</div>

Try this. In the file [Common/Core/vtkCompiler.h](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Common/Core/vtkCompiler.h#L50), remove `VTK_USE_EXTERN_TEMPLATE` for MinGW:

```auto
#if !defined( __MINGW32__ )
#define VTK_USE_EXTERN_TEMPLATE
#endif

```

Unfortunately I do not have MinGW, so I cannot test this myself.

---

<div class="post-metadata">

### Author: ![rockydut](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rockydut/32/4261_2.png) [@rockydut](https://discourse.vtk.org/u/rockydut)
#### Post date: [January 19, 2022, 4:38am UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/6 "2022-01-19T04:38:32Z")

</div>

It cannot compile passed by such setting.  
For vtk-9.0.1, it can easy to compile by mingw64 (by Msys2), however, I never compile correct for 9.1.0.  
Furtherore, I also got the following error:

CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate\_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate\_long.cxx:(.debug\_frame+0x1c): relocation truncated to fit: IMAGE\_REL\_AMD64\_SECREL against `.debug_frame' CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate_long.cxx:(.debug_frame+0x54): relocation truncated to fit: IMAGE_REL_AMD64_SECREL against `.debug\_frame’  
CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate\_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate\_long.cxx:(.debug\_frame+0x8c): relocation truncated to fit: IMAGE\_REL\_AMD64\_SECREL against `.debug_frame' CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate_long.cxx:(.debug_frame+0xc4): relocation truncated to fit: IMAGE_REL_AMD64_SECREL against `.debug\_frame’  
CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate\_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate\_long.cxx:(.debug\_frame+0xfc): relocation truncated to fit: IMAGE\_REL\_AMD64\_SECREL against `.debug_frame' CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate_long.cxx:(.debug_frame+0x134): relocation truncated to fit: IMAGE_REL_AMD64_SECREL against `.debug\_frame’  
CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate\_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate\_long.cxx:(.debug\_frame+0x16c): relocation truncated to fit: IMAGE\_REL\_AMD64\_SECREL against `.debug_frame' CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate_long.cxx:(.debug_frame+0x1a4): relocation truncated to fit: IMAGE_REL_AMD64_SECREL against `.debug\_frame’  
CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate\_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate\_long.cxx:(.debug\_frame+0x1dc): relocation truncated to fit: IMAGE\_REL\_AMD64\_SECREL against `.debug_frame' CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate_long.cxx:(.debug_frame+0x214): relocation truncated to fit: IMAGE_REL_AMD64_SECREL against `.debug\_frame’  
CMakeFiles\CommonCore.dir/objects.a(vtkGenericDataArrayValueRangeInstantiate\_long.cxx.obj):vtkGenericDataArrayValueRangeInstantiate\_long.cxx:(.debug\_frame+0x24c): additional relocation overflows omitted from the output  
collect2.exe: error: ld returned 1 exit status  
mingw32-make[2]: \*\*\* [Common\Core\CMakeFiles\CommonCore.dir\build.make:2830: bin/libvtkCommonCore-9.1d.dll] Error 1  
mingw32-make[1]: \*\*\* [CMakeFiles\Makefile2:4114: Common/Core/CMakeFiles/CommonCore.dir/all] Error 2  
mingw32-make: \*\*\* [Makefile:135: all] Error 2

---

<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: [January 21, 2022, 2:07pm UTC](https://discourse.vtk.org/t/compile-vtk-9-1-with-mingw-error/7464/7 "2022-01-21T14:07:05Z")

</div>

What version of Msys2 and MinGW64 are you using? Maybe you encountered a bug that has been fixed recently: [binutils 2.35 broken [relocation truncated to fit] · Issue #6986 · msys2/MINGW-packages · GitHub](https://github.com/msys2/MINGW-packages/issues/6986) .
