Compile vtk-9.1 with mingw-Error

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

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

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 .objs 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

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

Try this. In the file Common/Core/vtkCompiler.h, remove VTK_USE_EXTERN_TEMPLATE for MinGW:

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

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

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

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 .