Error launching my program with VTK

Hello everyone,

When I run my program in debug mode with VTK version 9.2, I get the following error :

In function `vtkGenericDataArray<vtkAOSDataArrayTemplate<long long>, long long>::SetValue(long long, long long)':
userPath/vtk-9.2/vtkGenericDataArray.h:122: undefined reference to `vtkAOSDataArrayTemplate<long long>::SetValue(long long, long long)'
In function `vtkGenericDataArray<vtkAOSDataArrayTemplate<int>, int>::SetValue(long long, int)':
userPath/vtk-9.2/vtkGenericDataArray.h:122: undefined reference to `vtkAOSDataArrayTemplate<int>::SetValue(long long, int)'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [userPath\build.make:1215: userPath/file.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:4642: userPath/all] Error 2
mingw32-make: *** [Makefile:110: all] Error 2
Error Level is 2

Has anyone come across this kind of error before? And if so, do you have a solution?
Thank you for reading,

Other people have reported this issue with mingw. This error is very specific to mingw, it does not occur when people build VTK with other compilers.

I suggest trying the following patch. I just found it in a google search, so I don’t know much about it:

If it works for you, then please let us know.

Edit: there is an open gcc-mingw issue about missing symbols for inline methods when code does explicit instantiation of class templates:

1 Like

Hi, thank you for your answer.
The patch change nothing to my error, I tried to update my version to 9.2.6 (nothing changed even with the patch).

As for the command (-Wl,–export-all-symbols), I tried to add it to my CMakeLists but nothing changed either…

If it helps your reflection, the error is only displayed in debug, when I execute in release everything works.

I’ll try to find other ways…

I finally added :

        target_compile_options(proj_name BEFORE PRIVATE -O3)
        target_compile_options(proj_name BEFORE PRIVATE -O3)

To my CMakeLists and it worked !
Thank you for the help David :slight_smile:

In other words, you enable optimization so that the inline methods of vtkAOSDataArrayTemplate and vtkSOADataArrayTemplate are fully inlined during compilation of your project. Hence, the compiler doesn’t generate symbol lookups for these methods. Kinda tricky, but it’s nice to have a solution.

1 Like

We should look at adopting that MinGW patch. Mind shepherding it into release and paraview/release @spyridon97?