# Using VTK in QT using Cmake

**URL:** https://discourse.vtk.org/t/using-vtk-in-qt-using-cmake/14478
**Category:** Support
**Created:** [August 25, 2024, 4:50pm UTC](https://discourse.vtk.org/t/using-vtk-in-qt-using-cmake/14478 "2024-08-25T16:50:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![amireza007](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amireza007/32/9203_2.png) [@amireza007](https://discourse.vtk.org/u/amireza007)
#### Post date: [August 25, 2024, 4:50pm UTC](https://discourse.vtk.org/t/using-vtk-in-qt-using-cmake/14478/1 "2024-08-25T16:50:21Z")

</div>

Hello,

I’m on Windows 11 and have been really struggling to include VTK into the QT. I am very new to VTK. I have built and installed VTK (via ninja) by enabling the following configurations set using `cmake-gui`:

1. `VTK_GROUP_Qt` set to `YES`
2. `VTK_QT_VERSION` set to `6`
3. `-DVTK_MODULE_ENABLE_GUISupprtQt` set to `YES`

- I have also `set QML2_IMPORT_PATH=/path/to/vtk/lib/qml/VTK.9.3` and `set QML_IMPORT_PATH=/path/to/vtk/lib/qml/VTK.9.3` into `cmd`.

Now, I have a Qt project in another directory, whose tree is as follows:

```bash
VTK Project
| + build
| | + Desktop_Qt_6_7_2_MSVC2019_64bit-Debug
| - CMakeLists.txt
| - CMakeLists.txt.user
| - main.cpp
| - Main.qml

```

and my VTK installation directory tree looks like this:

```bash
VTKBin
| + bin
| | - vtkcgns-9.3d.dll ... (.dll files)
| + include
| | + vtk-9.3
| | | + Octree ...
| | | - QQuickVTKRenderWindow.h ... (.h files)
| + lib
| | + cmake
| | | + vtk-9.3
| | | | - FindCGNS.cmake ... (.cmake files)
| | + qml
| | | + VTK.9.3
| | | | - plugins.qmltypes
| | | | - qmldir
| | | | - qmlvtkplugin.dll
| | + vtk-9.3
| | - vtkcgns-9.3.lib ... (.lib files)
| + share
| | + licenses
| | + vtk-9.3

```

In my Qt project, I have added the following to the `CmakeLists.txt` (`VTK_DIR` points to `/VTKBin/lib/cmake/vtk-9.3`)

```cmake
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
include_directories("C:/VTKBin/include/vtk-9.3/")
add_subdirectory(${VTK_DIR})

```

When I want to add the following into the `main.cpp` in order to setting up Graphics Backend (as explained in official Doxygen page [here](https://vtk.org/doc/nightly/html/classQQuickVTKRenderWindow.html#:~:text=QQuickVTKRenderWindow%3A%3AsetupGraphicsBackend()%3B)), I use `QQuickVTKRenderWindow::setupGraphicsBackend();` but I get a `LNK2019: unresolved external symbol` error for it. **Please, please help me! (or at least give me a hint of official vtk docs for this!)**

Thank you so much in advance,

Regards

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [August 26, 2024, 1:47pm UTC](https://discourse.vtk.org/t/using-vtk-in-qt-using-cmake/14478/2 "2024-08-26T13:47:59Z")

</div>

Hello,

Adding VTK only is not enough. You need to add Qt libraries as well. Please, take a look at this: [Building a QML application | Build with CMake 6.7.2 (qt.io)](https://doc.qt.io/qt-6/cmake-build-qml-application.html). It has a sample `CMakeLists.txt` that you can use to properly configure a Qt project with CMake.

best,

PC
