Day039 — How to include and link VTK, Boost and GLM in Visual Studio 2017 on Windows
In the last post, I demonstrated how to download and install VTK, Boost and GLM on Windows. It is time to include and link them in a Visual Studio 2017 project.
Setup VTK
I would recommend to use examples from VTK website as reference to setup the visual studio project as the project configuration is fairly complicated. By using the below link, you will be directed to the example website of VTK. I will be using the Sphere
example to demonstrate how to do the initial project setup. The example uses cmake to do the project generation. You can modify the CMakeLists.txt to suit your needs.
https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/Sphere/
Here is the process of generating the visual studio project.
- open CMake GUI (3.9.1)
- set
Where is the source code
to be thevtkSphere
directory - set
Where to build the binaries
to bevtkSphere/build
directory - click
configure
- select
Visual Studio 15 2017 Win64
andUse default native compilers
as I am using a 64 bit computer - after configuration is done, click
generate
to generate the visual studio progect - After it is generated, click
open project
. The project should be opened using visual studio - In the Solution Explorer panel, right click
ALL_BUILD
and clickbuild
to build - In the output panel, check if all projects are built successfully
- In the Solution Explorer panel, right click
Sphere
and clickSet as StartUp Project
- Press
F5
or clickLocal Windows Debugger
at the Standard Toolbar to start Debugging - A sphere in a green background should appear. You can long press left click to rotate it, and long press right click then move up or down to zoom in or out.
Visual Studio 15 2017 Win64
and Use default native compilers
ALL_BUILD
and click build
to buildLocal Windows Debugger
at the Standard Toolbar to start DebuggingSetup Boost and GLM
By using the Sphere example as base, I then include necessary directories of Boost and GLM.
- In the
Solution Explorer
panel, right clickSphere
and selectproperties
. - On the left hand side of the dialog, navigate to
Configuration Properties
>C/C++
>General
- add
C:\local\boost_1_65_1
andC:\local\glm\glm
toAdditional Include Directories
- Then, navigate to
Configuration Properties
>Linker
>General
- add
C:\local\boost_1_65_1\lib64-msvc-14.1
toAdditional Library Directories
Please notice that the version of Boost and C++ compiler you are using. For my case, I am using a 64-bit computer and VS 2017 build tool (v14.1). The boost version is 1.65.1
. Therefore, the folder name is boost_1_65_1
and the folder holding the pre-built library is lib64-msvc-14.1
. You should modify the path name added to visual studio according to your running version.
Additional Include Directories
Additional Library Directories
Done
By now, all the configuration is done. The project should be built successfully. That is the configuration I used to build a project that involves VTK, Boost and GLM. Let me know if anything is broken.