# Error launching my program with VTK

**URL:** <https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666>\
**Category:** Support\
**Created:** [November 9, 2023, 3:45pm UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666 "2023-11-09T15:45:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guilhem](https://discourse.vtk.org/user_avatar/discourse.vtk.org/guilhem/32/7980_2.png) [@Guilhem](https://discourse.vtk.org/u/Guilhem)\
**Post date:** [November 9, 2023, 3:45pm UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666/1 "2023-11-09T15:45:46Z")

</div>

Hello everyone,

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

```auto
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,  
Guilhem.

---

<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:** [November 10, 2023, 3:06pm UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666/2 "2023-11-10T15:06:29Z")

</div>

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:  
[https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-vtk/007-dll-export-some-functions.patch](https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-vtk/007-dll-export-some-functions.patch)

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:  
[https://gcc.gnu.org/bugzilla/show\_bug.cgi?id=89088](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89088)

---

<div class="post-metadata">

**Author:** ![Guilhem](https://discourse.vtk.org/user_avatar/discourse.vtk.org/guilhem/32/7980_2.png) [@Guilhem](https://discourse.vtk.org/u/Guilhem)\
**Post date:** [November 13, 2023, 9:07am UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666/3 "2023-11-13T09:07:12Z")

</div>

> [@dgobbi](#):
>
> s an open gcc-mingw issue about missing symbols for inline methods when code does explicit instantiation of class templates:

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…

---

<div class="post-metadata">

**Author:** ![Guilhem](https://discourse.vtk.org/user_avatar/discourse.vtk.org/guilhem/32/7980_2.png) [@Guilhem](https://discourse.vtk.org/u/Guilhem)\
**Post date:** [November 14, 2023, 2:27pm UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666/4 "2023-11-14T14:27:56Z")

</div>

I finally added :

```auto
if (CMAKE_BUILD_TYPE MATCHES Release)
        target_compile_options(proj_name BEFORE PRIVATE -O3)
else()
        target_compile_options(proj_name BEFORE PRIVATE -O3)
endif()

```

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

---

<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:** [November 14, 2023, 2:39pm UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666/5 "2023-11-14T14:39:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [November 17, 2023, 4:12am UTC](https://discourse.vtk.org/t/error-launching-my-program-with-vtk/12666/6 "2023-11-17T04:12:12Z")

</div>

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