VTK Module Init error.

(Kim William) #1

Hi all.

I have a question about VTK_MODULE_INIT.

My environment is as below:
IDE: Visual Studio 2015 MFC (dialog based project)
SDK: VTK 8.9

I have tested the sample code ‘LinePlot’.
Link: https://lorensen.github.io/VTKExamples/site/Cxx/Plotting/LinePlot/

And I made a project file based on ‘LinePlot’, and inserted the macro:
VTK_MODULE_INIT(vtkRenderingContextOpenGL2);
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);

It works well. There is no problem.

But, the other new project has a problem.

I really don’t know how can I resolve this problem.

Could you please help me?

Thank you

(Ben Boeckel) #2

Are you using 8.2 or master? Oh, I see the “8.9” mention above. There should be no need to add VTK_MODULE_INIT calls manually. Instead, in your CMakeLists.txt, using vtk_module_autoinit should handle it. If you’re not using CMake, you’ll want something like:

#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2,vtkInteractionStyle)
#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL2)

at the very top should work. You’ll need to link all of the mentioned libraries.

(Kim William) #3

Hi Ben.

I tried to test with the code as below:

#include <vtkAutoInit.h>
#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2,vtkInteractionStyle)
#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL2)

#include <vtkContextView.h>
#include <vtkChartXY.h>
#include <vtkContextScene.h>
#include <vtkAxis.h>
#include <vtkTextProperty.h>
#include <vtkPen.h>
#include <vtkPlot.h>

But the symptom is the same.

Is there another way to solve this issue? :cry:

Thank you

(Ben Boeckel) #4

Are you also linking to the vtkRenderingOpenGL2 and other mentioned libraries?

(Kim William) #5

Yes, I have input all the libraries list.

I found something strange.
If I create a new project about the VTK chart example, it works well.
There is no problem.

All configurations are the same.
But… I don’t have an idea about what is the problem…

(Ben Boeckel) #6

You’re also missing vtkRenderingContextOpenGL2 and vtkRenderingContext2D it seems. Please paste the full library list you’re linking against.

(Kim William) #7

Hi Ben.

Thank you for your help :slight_smile:

There are include list:

#include <vtkAutoInit.h>

#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2,vtkInteractionStyle)
#define vtkRenderingContext2D_AUTOINIT 2(vtkRenderingContextOpenGL2, vtkRenderingContext2D)

#include <vtkRenderWindow.h>
#include <vtkSmartPointer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkRenderer.h>
#include <vtkObject.h>

#include <vtkPLYReader.h>
#include <vtkLookupTable.h>
#include <vtkPointGaussianMapper.h>
#include <vtkActor.h>
#include <vtkAxesActor.h>
#include <vtkTransform.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkHandleWidget.h>
#include <vtkDelimitedTextReader.h>
#include <vtkTable.h>
#include <vtkDoubleArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkVertexGlyphFilter.h>
#include <vtkVersionMacros.h>
#include <vtkProperty.h>
#include <vtkPolyDataMapper.h>
#include <vtkNamedColors.h>
#include <vtkFloatArray.h>

#include <vtkProperty.h>
#include <vtkPointData.h>
#include <vtkScalarBarActor.h>
#include <vtkColorSeries.h>
#include <vtkColorTransferFunction.h>
#include <vtkDataSetMapper.h>
#include <vtkPropPicker.h>
#include <vtkObjectFactory.h>
#include <vtkCellPicker.h>
#include <vtkAreaPicker.h>
#include <vtkContextView.h>
#include <vtkChartXY.h>
#include <vtkContextScene.h>
#include <vtkAxis.h>
#include <vtkTextProperty.h>
#include <vtkPen.h>
#include <vtkPlot.h>

And additional library list:

vtkChartsCore-8.90d.lib
vtkCommonColor-8.90d.lib
vtkCommonComputationalGeometry-8.90d.lib
vtkCommonCore-8.90d.lib
vtkCommonDataModel-8.90d.lib
vtkCommonExecutionModel-8.90d.lib
vtkCommonMath-8.90d.lib
vtkCommonMisc-8.90d.lib
vtkCommonSystem-8.90d.lib
vtkCommonTransforms-8.90d.lib
vtkDICOMParser-8.90d.lib
vtkDomainsChemistry-8.90d.lib
vtkdoubleconversion-8.90d.lib
vtkexodusII-8.90d.lib
vtkexpat-8.90d.lib
vtkFiltersAMR-8.90d.lib
vtkFiltersCore-8.90d.lib
vtkFiltersExtraction-8.90d.lib
vtkFiltersFlowPaths-8.90d.lib
vtkFiltersGeneral-8.90d.lib
vtkFiltersGeneric-8.90d.lib
vtkFiltersGeometry-8.90d.lib
vtkFiltersHybrid-8.90d.lib
vtkFiltersHyperTree-8.90d.lib
vtkFiltersImaging-8.90d.lib
vtkFiltersModeling-8.90d.lib
vtkFiltersParallel-8.90d.lib
vtkFiltersParallelImaging-8.90d.lib
vtkFiltersPoints-8.90d.lib
vtkFiltersProgrammable-8.90d.lib
vtkFiltersSelection-8.90d.lib
vtkFiltersSMP-8.90d.lib
vtkFiltersSources-8.90d.lib
vtkFiltersStatistics-8.90d.lib
vtkFiltersTexture-8.90d.lib
vtkFiltersTopology-8.90d.lib
vtkFiltersVerdict-8.90d.lib
vtkfreetype-8.90d.lib
vtkGeovisCore-8.90d.lib
vtkgl2ps-8.90d.lib
vtkglew-8.90d.lib
vtkhdf5-8.90d.lib
vtkhdf5_hl-8.90d.lib
vtkImagingColor-8.90d.lib
vtkImagingCore-8.90d.lib
vtkImagingFourier-8.90d.lib
vtkImagingGeneral-8.90d.lib
vtkImagingHybrid-8.90d.lib
vtkImagingMath-8.90d.lib
vtkImagingMorphological-8.90d.lib
vtkImagingSources-8.90d.lib
vtkImagingStatistics-8.90d.lib
vtkImagingStencil-8.90d.lib
vtkInfovisCore-8.90d.lib
vtkInfovisLayout-8.90d.lib
vtkInteractionImage-8.90d.lib
vtkInteractionStyle-8.90d.lib
vtkInteractionWidgets-8.90d.lib
vtkIOAMR-8.90d.lib
vtkIOAsynchronous-8.90d.lib
vtkIOCityGML-8.90d.lib
vtkIOCore-8.90d.lib
vtkIOEnSight-8.90d.lib
vtkIOExodus-8.90d.lib
vtkIOExport-8.90d.lib
vtkIOExportGL2PS-8.90d.lib
vtkIOExportPDF-8.90d.lib
vtkIOGeometry-8.90d.lib
vtkIOImage-8.90d.lib
vtkIOImport-8.90d.lib
vtkIOInfovis-8.90d.lib
vtkIOLegacy-8.90d.lib
vtkIOLSDyna-8.90d.lib
vtkIOMINC-8.90d.lib
vtkIOMotionFX-8.90d.lib
vtkIOMovie-8.90d.lib
vtkIONetCDF-8.90d.lib
vtkIOOggTheora-8.90d.lib
vtkIOParallel-8.90d.lib
vtkIOParallelXML-8.90d.lib
vtkIOPLY-8.90d.lib
vtkIOSegY-8.90d.lib
vtkIOSQL-8.90d.lib
vtkIOTecplotTable-8.90d.lib
vtkIOVeraOut-8.90d.lib
vtkIOVideo-8.90d.lib
vtkIOXML-8.90d.lib
vtkIOXMLParser-8.90d.lib
vtkjpeg-8.90d.lib
vtkjsoncpp-8.90d.lib
vtklibharu-8.90d.lib
vtklibproj-8.90d.lib
vtklibxml2-8.90d.lib
vtkloguru-8.90d.lib
vtklz4-8.90d.lib
vtklzma-8.90d.lib
vtkmetaio-8.90d.lib
vtknetcdf-8.90d.lib
vtkogg-8.90d.lib
vtkParallelCore-8.90d.lib
vtkpng-8.90d.lib
vtkpugixml-8.90d.lib
vtkRenderingAnnotation-8.90d.lib
vtkRenderingContext2D-8.90d.lib
vtkRenderingCore-8.90d.lib
vtkRenderingFreeType-8.90d.lib
vtkRenderingGL2PSOpenGL2-8.90d.lib
vtkRenderingImage-8.90d.lib
vtkRenderingLabel-8.90d.lib
vtkRenderingLOD-8.90d.lib
vtkRenderingOpenGL2-8.90d.lib
vtkRenderingParallel-8.90d.lib
vtkRenderingVolume-8.90d.lib
vtkRenderingVolumeOpenGL2-8.90d.lib
vtksqlite-8.90d.lib
vtksys-8.90d.lib
vtkTestingRendering-8.90d.lib
vtktheora-8.90d.lib
vtktiff-8.90d.lib
vtkverdict-8.90d.lib
vtkViewsCore-8.90d.lib
vtkViewsInfovis-8.90d.lib
vtkWrappingTools-8.90d.lib
vtkzlib-8.90d.lib
(Kim William) #8

Oh… Ben!

I found that I missed the ‘vtkRenderingContextOpenGL2-8.90d.lib’!

So sorry and thank you for your help :slight_smile: