Visual studio 2013 compiles vtk7.1.0

1. Download the VTK

Source, Data, and Documentation can be downloaded from the VTK website:
VTK Download

There are two ways to install VTK: binary install and source code install. Binary install can download VTK. Exe to install VTK directly, and development can be carried out directly in TCL. Source code install needs to download CMake to configure/generate, development can use C++, Java,Python, TCL and other any way, so this article download source to compile.

Unzip the Source to D:\ vtk-7.1.0.

To install CMake, see:
CMake

2. Run CMake to configure VTK

Run CMake and configure the source code path and target path:



Select Visual Studio 12 2013 Win64 as the Current Generator, click Configure, and the red scan results will appear. Check the options according to your own needs and explain some of the options:

CMAKE_INSTALL_PREFIX is the default installation path and the place where the INSTALL project is generated. You can select D:/ vtk-7.1.0-build /.

Build recommends checking the following box:


Don’t worry about the contents under the Install option; the default value is fine.

If you want to use Python, you need to check VTK_WRAP_PYHTON and configure the appropriate path under the Python option. Otherwise, you will get a CMake Could NOT find PythonLibs error.


INCLUDE_DIR is included after Configure again.

If Qt environment variable QTDIR is configured in the system, and %QTDIR%/bin is added in PATH, then Qt partial options will be the default.

Check VTK_Group as needed:



Reset Configure, then Generate.

3. Generate VTK

Open vtk.sln under D:\ vtkv7-build, right-click ALL_BUILD and select regenerate. This step takes a long time.

There will be some link errors after the first generation, such as not open.. \.. The vtkviewsinfovispython27d-7.1. lib file under \lib\Debug may be generated in order, so it can be regenerated to reduce some errors.

After the build is successful, find the Install project, right-click and select For Project Only ->; Only INSTALL is generated, and the include directory is generated under the CMAKE_INSTALL_PREFIX setting, which contains the header files required by the VTK.

4. Error resolution
4.1 vtkWrappingPythonCore project cannot open file “python27.lib”

Locate the project and add the additional link library D:\S\D\python-install\libs in the properties

4.2 The vtkimagingcameron project cannot open the file ‘.. \.. \ lib \ Debug \ vtkCommonDataModelPython27D – 7.1. Lib”

Find the project associated with VTKCommonDataModel and look at the properties ->; The linker – & gt; Advanced import libraries in the part, is the output.lib file, after the project is to generate the view, vtkCommonDataModelPython output for vtkCommonDataModelPython. Lib, and the output of the vtkCommonDataModelPythonD project vtkCommonDataModelPython27D – 7.1 lib, so can’t open the file Python27D – 7.1. Lib errors, Build the corresponding Pythond project, and add the Python \libs directory to the additional libraries for that project.

Note: Since it is too cumbersome to add Python, and the project does not need Python, so Python is cancelled and recompiled, and the VTK used subsequently does not add Python.

5. Run the Examples
5.1 CMake compilation

Run CMake, source code position select the source code, for example: D:/VTK – 7.1.0/Examples/Tutorial/Step1/Cxx, build the binaries choose project files are generated, for example: D:/VTKCode/Step1.

VTK_DIR = D:\ vtk-7.1.0-build; CMAKE_INSTALL_PREFIX = INSTALL. Vcxproj; C :\ vtk-7.1.0-build; CMAKE_INSTALL_PREFIX = INSTALL. Vtk-7.1.0-build; CMAKE_INSTALL_PREFIX = INSTALL.

After compilation, go to the project file directory and find Step1.sln. After opening it, select Cone as the startup project for generation. After successful generation, it can be run.

5.2 New project compilation

Start the VS2013, create a new empty project, will be D:/VTK – 7.1.0/Examples/Tutorial/Step1/Cxx/Cone. Cxx is copied to the new project directory, Cone is added in the new project. The Cxx to the source file.

To configure the properties of the project, in the VC++ directory, the include directory adds the generated include file, for example: D:\ vtk-7.1.0-build \include\vtk-7.1, and the library directory adds the lib file, for example: D:\ vtk-7.1.0-build \lib.

The additional dependencies of the linker are filled into all.lib files in the lib directory, as shown below:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
comctl32.lib
vfw32.lib
ws2_32.lib
wsock32.lib
opengl32.lib
vtkalglib-7.1.lib
vtkChartsCore-7.1.lib
vtkCommonColor-7.1.lib
vtkCommonComputationalGeometry-7.1.lib
vtkCommonCore-7.1.lib
vtkCommonDataModel-7.1.lib
vtkCommonExecutionModel-7.1.lib
vtkCommonMath-7.1.lib
vtkCommonMisc-7.1.lib
vtkCommonSystem-7.1.lib
vtkCommonTransforms-7.1.lib
vtkDICOMParser-7.1.lib
vtkDomainsChemistry-7.1.lib
vtkDomainsChemistryOpenGL2-7.1.lib
vtkexoIIc-7.1.lib
vtkexpat-7.1.lib
vtkFiltersAMR-7.1.lib
vtkFiltersCore-7.1.lib
vtkFiltersExtraction-7.1.lib
vtkFiltersFlowPaths-7.1.lib
vtkFiltersGeneral-7.1.lib
vtkFiltersGeneric-7.1.lib
vtkFiltersGeometry-7.1.lib
vtkFiltersHybrid-7.1.lib
vtkFiltersHyperTree-7.1.lib
vtkFiltersImaging-7.1.lib
vtkFiltersModeling-7.1.lib
vtkFiltersParallel-7.1.lib
vtkFiltersParallelImaging-7.1.lib
vtkFiltersPoints-7.1.lib
vtkFiltersProgrammable-7.1.lib
vtkFiltersSelection-7.1.lib
vtkFiltersSMP-7.1.lib
vtkFiltersSources-7.1.lib
vtkFiltersStatistics-7.1.lib
vtkFiltersTexture-7.1.lib
vtkFiltersVerdict-7.1.lib
vtkfreetype-7.1.lib
vtkGeovisCore-7.1.lib
vtkgl2ps-7.1.lib
vtkglew-7.1.lib
vtkGUISupportQt-7.1.lib
vtkGUISupportQtSQL-7.1.lib
vtkhdf5_hl-7.1.lib
vtkhdf5-7.1.lib
vtkImagingColor-7.1.lib
vtkImagingCore-7.1.lib
vtkImagingFourier-7.1.lib
vtkImagingGeneral-7.1.lib
vtkImagingHybrid-7.1.lib
vtkImagingMath-7.1.lib
vtkImagingMorphological-7.1.lib
vtkImagingSources-7.1.lib
vtkImagingStatistics-7.1.lib
vtkImagingStencil-7.1.lib
vtkInfovisCore-7.1.lib
vtkInfovisLayout-7.1.lib
vtkInteractionImage-7.1.lib
vtkInteractionStyle-7.1.lib
vtkInteractionWidgets-7.1.lib
vtkIOAMR-7.1.lib
vtkIOCore-7.1.lib
vtkIOEnSight-7.1.lib
vtkIOExodus-7.1.lib
vtkIOExport-7.1.lib
vtkIOGeometry-7.1.lib
vtkIOImage-7.1.lib
vtkIOImport-7.1.lib
vtkIOInfovis-7.1.lib
vtkIOLegacy-7.1.lib
vtkIOLSDyna-7.1.lib
vtkIOMINC-7.1.lib
vtkIOMovie-7.1.lib
vtkIONetCDF-7.1.lib
vtkIOParallel-7.1.lib
vtkIOParallelXML-7.1.lib
vtkIOPLY-7.1.lib
vtkIOSQL-7.1.lib
vtkIOTecplotTable-7.1.lib
vtkIOVideo-7.1.lib
vtkIOXML-7.1.lib
vtkIOXMLParser-7.1.lib
vtkjpeg-7.1.lib
vtkjsoncpp-7.1.lib
vtklibxml2-7.1.lib
vtkLocalExample-7.1.lib
vtkmetaio-7.1.lib
vtkNetCDF_cxx-7.1.lib
vtkNetCDF-7.1.lib
vtkoggtheora-7.1.lib
vtkParallelCore-7.1.lib
vtkpng-7.1.lib
vtkproj4-7.1_d.lib
vtkRenderingAnnotation-7.1.lib
vtkRenderingContext2D-7.1.lib
vtkRenderingContextOpenGL2-7.1.lib
vtkRenderingCore-7.1.lib
vtkRenderingFreeType-7.1.lib
vtkRenderingGL2PSOpenGL2-7.1.lib
vtkRenderingImage-7.1.lib
vtkRenderingLabel-7.1.lib
vtkRenderingLOD-7.1.lib
vtkRenderingOpenGL2-7.1.lib
vtkRenderingQt-7.1.lib
vtkRenderingVolume-7.1.lib
vtkRenderingVolumeOpenGL2-7.1.lib
vtksqlite-7.1.lib
vtksys-7.1.lib
vtkTestingGenericBridge-7.1.lib
vtkTestingIOSQL-7.1.lib
vtkTestingRendering-7.1.lib
vtktiff-7.1.lib
vtkverdict-7.1.lib
vtkViewsContext2D-7.1.lib
vtkViewsCore-7.1.lib
vtkViewsInfovis-7.1.lib
vtkViewsQt-7.1.lib
vtkzlib-7.1.lib

Note that this configuration does not copy the.dll file to C:\ windows\ System32 or C:\ windows\ SysWOW64, if it is Win7 need to copy, the native system is Win10, only added in the Path of VTK. DLL file directory.

Since the native system is a 64-bit system, VTK. SLN is compiled with Debug X64 selected, so the new project should be built successfully by changing the active solution platform to X64 in the configuration manager.

Error: No Override found for ‘VTKPolydataMapper ‘. CMAKE is not used for configuration, so you need to add the following code at the beginning of the source code:

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);

This method is applicable to VTK7.0 and above, other versions can refer to the following information:

VTK/VTK 6 Migration/Factories now require defines

VTK/Build System Migration

6. References

Getting Started with VTK (Configuration + FAQ)

VTK installation in VS2010 (including Python) and the first example

Detailed installation guide for VTK and ITK

ITK + VTK + QT on Window 7 64bit and Visual Studio 2010 Pro 32bit project

Read More: