Day039 — How to include and link VTK, Boost and GLM in Visual Studio 2017 on Windows

Jacky Tsang
3 min readDec 27, 2017

--

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/

The project is structured like this

Here is the process of generating the visual studio project.

  1. open CMake GUI (3.9.1)
  2. set Where is the source code to be the vtkSphere directory
  3. set Where to build the binaries to be vtkSphere/build directory
  4. click configure
  5. select Visual Studio 15 2017 Win64 and Use default native compilers as I am using a 64 bit computer
  6. after configuration is done, click generate to generate the visual studio progect
  7. After it is generated, click open project. The project should be opened using visual studio
  8. In the Solution Explorer panel, right click ALL_BUILD and click build to build
  9. In the output panel, check if all projects are built successfully
  10. In the Solution Explorer panel, right click Sphere and click Set as StartUp Project
  11. Press F5 or click Local Windows Debugger at the Standard Toolbar to start Debugging
  12. 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.
Step 5: select Visual Studio 15 2017 Win64 and Use default native compilers
Step 8: right click ALL_BUILD and click build to build
Step 9: check if all projects are built successfully
Step 11: click Local Windows Debugger at the Standard Toolbar to start Debugging
Step 12: A sphere in a green background should appear

Setup Boost and GLM

By using the Sphere example as base, I then include necessary directories of Boost and GLM.

  1. In the Solution Explorer panel, right click Sphere and select properties.
  2. On the left hand side of the dialog, navigate to Configuration Properties > C/C++ > General
  3. add C:\local\boost_1_65_1 and C:\local\glm\glm to Additional Include Directories
  4. Then, navigate to Configuration Properties > Linker > General
  5. add C:\local\boost_1_65_1\lib64-msvc-14.1 to Additional 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.

Step 3: Additional Include Directories
Step 5: 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.

--

--

Responses (1)