[VTK Study Notes-01] Use CMake and VS to compile the VTK library source code (simple version)

1. Preparation

CMake, Visual Studio, VTK source code

2.General process

(1) Create a new VTK folder, and create three subfolders at the lower level: vtk_source, vtk_prefix, and vtk_install

  • vtk_source: stores the decompressed source code of vtk
  • vtk_prefix: used to store the results generated by compiling the vtk.sln file
  • vtk_install: stores CMake compiled files

(2) Download CMake from the official website, open it, and specify the source code path vtk_source and the installation path vtk_install

  • Configure for the first time
  • Check the relevant configurations and perform the second configure
  • There is no red block and "configuring done!" is displayed below.
  • Click generate to generate relevant files, and "generate done!" is displayed below.

(3) Download Visual Studio from the official website, install and compile

  • Open the CMake compiled file vtk.sln in the vtk_install folder in the previous step
  • Set ALL_BUILD as the startup item (Generate-Generate Solution) and compile the project
  • Find the Install file in the solution, right-click -> Use only for project -> Generate INSTALL only.
    The relevant bin(.dll), lib(.lib), and include(.h) will be extracted from the previously selected vtk-prefix folder, which is what is needed to add environment variables, dependent libraries, and header files later.

(4) Test the VTK compilation results and build a console application for testing. There are two methods (not complete yet, to be modified)
(4-1) Use CMake to manage VTK projects

  • Fill in the relevant configuration in CMakeList.txt, and fill in the relevant code in cpp
  • Open CMake, follow the previous method, fill in the path, configure, generate

(4-2) Manually configure VTK project in VS

  • Create a new console application and create a new cpp file in the project
  • (View-Property Manager)
  • Add dependent library files

3. Reference articles

VTK installation configuration-use VS2010
02-VTK to compile and install

Guess you like

Origin blog.csdn.net/m0_51141265/article/details/132588128