# vtk 8.2 MFC examples don't work

**URL:** https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823
**Category:** Support
**Created:** [April 23, 2019, 7:06pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823 "2019-04-23T19:06:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Sean](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@Sean](https://discourse.vtk.org/u/Sean)
#### Post date: [April 23, 2019, 7:06pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/1 "2019-04-23T19:06:22Z")

</div>

I am trying to upgrade to vtk8.2.0 (VS2017) and tested it with vtkMFC examples. Now run into some problems. I just couldn’t execute any of the three projects (vtkDLG, vtkMDI, and vtkSDI) with vtk error messages:

Generic Warning: In C:\VTK-8.2.0\Rendering\Core\vtkPolyDataMapper.cxx, line 28  
Error: no override found for ‘vtkPolyDataMapper’.

Warning: In C:\VTK-8.2.0\Rendering\Core\vtkInteractorStyleSwitchBase.cxx, line 39  
vtkInteractorStyleSwitchBase (0000021D4A64FA00): Warning: Link to vtkInteractionStyle for default style selection.

and then stop at (as an example for vtkDLG)

void vtkOpenGLRenderWindow::ActivateTexture(vtkTextureObject \*texture)  
–\> glActiveTexture(GL\_TEXTURE0 + activeUnit);

with error:

Exception thrown at 0x0000000000000000 in vtkDLG.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

I tried added the following code based on some suggestions, no luck for me

#include “vtkAutoInit.h”  
VTK\_MODULE\_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2  
VTK\_MODULE\_INIT(vtkInteractionStyle);

Any things I missed? Please help!

Thank you very much.

Sean

---

<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: [April 24, 2019, 1:17pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/2 "2019-04-24T13:17:29Z")

</div>

Should `VTK_DEFINTIONS` be used in the examples?

---

<div class="post-metadata">

### Author: ![Sean](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@Sean](https://discourse.vtk.org/u/Sean)
#### Post date: [April 24, 2019, 2:53pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/3 "2019-04-24T14:53:07Z")

</div>

> [@ben.boeckel](#):
>
> VTK\_DEFINTIONS

Thanks for your prompt reply. Could you further explain how to use VTK\_DEFINITIONS?

---

<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: [April 24, 2019, 3:37pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/4 "2019-04-24T15:37:23Z")

</div>

Something like `compile_definitions(${VTK_DEFINITIONS})`. This is where the normal autoinit stuff comes into play for 8.2.

---

<div class="post-metadata">

### Author: ![Sean](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@Sean](https://discourse.vtk.org/u/Sean)
#### Post date: [April 24, 2019, 4:17pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/5 "2019-04-24T16:17:51Z")

</div>

> [@ben.boeckel](#):
>
> compile\_definitions(${VTK\_DEFINITIONS})

Thanks. I tried and it is still the same issue.

---

<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: [April 24, 2019, 5:15pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/6 "2019-04-24T17:15:26Z")

</div>

Hmm. I’m not sure then. Are you seeing `-D<blahblah>_AUTOINIT=` arguments on the command lines compiling the sources?

---

<div class="post-metadata">

### Author: ![Sean](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@Sean](https://discourse.vtk.org/u/Sean)
#### Post date: [April 24, 2019, 6:06pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/7 "2019-04-24T18:06:50Z")

</div>

I copy and paste my Preprocessor Definitions as following, for your reference. I just tried SampleMFC example and it worked well after I removed some obsolete MFC code. I am trying to compare the code between these two project (vtkMFC and SampleMFC), and hopefully can find the issue. Thanks.

WIN32  
\_WINDOWS  
vtkDomainsChemistry\_AUTOINIT=1(vtkDomainsChemistryOpenGL2)  
vtkIOExport\_INCLUDE=“C:/OS20190322/VTKExamples/CMakeFiles/vtkIOExport\_AUTOINIT\_vtkIOExportOpenGL2\_vtkIOExportPDF.h”  
vtkRenderingContext2D\_AUTOINIT=1(vtkRenderingContextOpenGL2)  
vtkRenderingCore\_INCLUDE=“C:/OS20190322/VTKExamples/CMakeFiles/vtkRenderingCore\_AUTOINIT\_vtkInteractionStyle\_vtkRenderingFreeType\_vtkRenderingOpenGL2.h”  
vtkRenderingOpenGL2\_AUTOINIT=1(vtkRenderingGL2PSOpenGL2)  
vtkRenderingVolume\_AUTOINIT=1(vtkRenderingVolumeOpenGL2)  
\_AFXDLL  
GLEW\_STATIC  
CMAKE\_INTDIR=“Debug”

---

<div class="post-metadata">

### Author: ![Sean](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@Sean](https://discourse.vtk.org/u/Sean)
#### Post date: [April 30, 2019, 12:22pm UTC](https://discourse.vtk.org/t/vtk-8-2-mfc-examples-dont-work/823/8 "2019-04-30T12:22:56Z")

</div>

I could not figure out exactly what went wrong. However, after I switch Visual Studio from 2017 to 2019 (express), all issues are gone.
