[VTK] vtk8.2.0 + vs2015 + win10 compilation and configuration

VTK8.2.0 + VS2015 + Win10 compilation and configuration
Special thanks to the “cook a delicious fish” blogger for technical support please refer to: VTK8.2.0+ITK4.13.2+VS2015 configuration
Only the VTK library is compiled here, not the examples and data contained in the VTK.
because the project needs to use only the VS2015 version, and the compilation process is also applicable to VS2017 and VS2019;
1 Download the source code
1.1 VTK source code can be downloaded from VTK official website
Download address: https://vtk.org/download/

in 8.2.0 release version of the Source select a package to download.
1.2 CMake official website download
Download address: https://cmake.org/download/

select the latest Release version, choose according to your Windows Platform, I am a 64 – bit system, so choose Windows win64 – X64 Installer installation package, download can be installed directly after, best as an administrator to install.
2. Generate VS2015 project file of VTK using CMAKE
Unzip the VTK source code to get the vtk-8.2.0 folder, open it and see if there is a layer of VTK8.2.0 available when creating a new folder vtk-8.2.0-build and vtk-8.2.0-prefix.

2.1 Open the installed Cmake (cmak-gui) (please ignore that my version is not the latest version) and select the VTK source path and the VTK generation path as the previous step, click Configure.

I am VS2015 64-bit version, click Finish to start loading the configuration and wait until the red area appears and the Configuring done appears.


2.3 Modify configuration parameters
2.3.1 Tickle BUILD_SHARED_LIBS under Build (I didn’t check it for example tests if I want to check it)
2.3.2 Modify the CMAKE_INSTALL_PREFIX option path to the vtk-8.2.0-prefix path created earlier
2.3.3 If you want to support MFC, check the MODULE_VTKGUISUPPORTMFC option under Module
2.3.4 Click the Configure button until the red part disappears, and click the Generate button to Generate the project file
2.3.5 Here refer to “VTK8.2.0 Compile, Installation and Test Case Run (Win10 + VS2017 + QT5, Release+Debug)” to set the value of CMAKE_DEBUG_POSTFIX. This variable represents the character added after the output filename in Debug mode, set to “_D”, then the filename generated in Debug mode will have the suffix “_D”. In order to distinguish between the files used in Release and Debug mode (I did not set it, you can set it, so that when you create a Release after the Debug version, you will not overwrite the files you created before)



3 Enter the generated VS2015 project file and compile the VTK library
3.1 Open before the new VTK-8.2.0-Build folder, use VS2015 to open VTK. SLN (it is best to open Win10 as an administrator to modify C disk data is very sensitive, may lead to compilation failure, close 360 and other defense software, close no necessary programs)
3.2 The default attribute is debug x64, right-click ALL_BUILD and select Build for compilation. It is better not to operate the computer during the Build period. After completion, check whether the output is all successful.


3.3 Copy the include, bin, lib, and share files from the vtk-8.2.0-prefix files to your own VTK library folder. For example: Create a new VTK820 folder with Debug and Release, because include and share files are shared by debug and release versions, put include and share folders in VTK820, and copy the generated bin and lib files to the corresponding folders. For example, the bin and lib files generated by vtk-8.2.0-prefix under debug environment are placed in the Debug folder of VTK820.

3.4 After changing Debug to Release in VS2015, repeat the operation of 3.2 to generate the Release version of VTK library (note: the bin and lib generated under vtk-8.2.0-prefix will be overwritten and copied ahead of time). Save the library files to the Release as described in 3.3

4. Use of VTK
Configure the VTK library, including (1) add the environment variable VTK820 bin folder directory (debug and release used to fill which is OK) (after configuration need to restart VS or restart the computer), create a new console application (2) modify the project properties contain directory and lib library directory, (3) and use the lib file name to Link->; Iput-> Additional Dependencies (there is a method to get all the lib names, create a new.txt file under the lib file, and type dir /b *.lib>;

ah
a>

Read More: