# Is there a way to compile the VTK to a single dll

**URL:** https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948
**Category:** Support
**Created:** [December 21, 2023, 3:59pm UTC](https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948 "2023-12-21T15:59:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![WangZP10969](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wangzp10969/32/2579_2.png) [@WangZP10969](https://discourse.vtk.org/u/WangZP10969)
#### Post date: [December 21, 2023, 3:59pm UTC](https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948/1 "2023-12-21T15:59:29Z")

</div>

When I use vtk, I use a lot of dlls, I was wondering if there is a way to modify the cmake configuration to implement a single dll.

I tried to retrieve all the cxx files to generate a single library project, but there are a lot of compilation errors, it is difficult to deal with them one by one.

I’ve tried compiling the VTK statically and then dynamically compiling the required interface to the dll, and when I only use vtk, it’s successful. But when I need to work with dynamically compiled QT, it will appear like accessing a null pointer when I run it, or there will be no result when I run it.

any suggestions for this?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [December 21, 2023, 4:56pm UTC](https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948/2 "2023-12-21T16:56:37Z")

</div>

You can reduce the number of DLLs with the `VTK_ENABLE_KITS` option. There was discussion about making a single “mega kit” library but it never materialized.

---

<div class="post-metadata">

### Author: ![WangZP10969](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wangzp10969/32/2579_2.png) [@WangZP10969](https://discourse.vtk.org/u/WangZP10969)
#### Post date: [December 22, 2023, 8:35am UTC](https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948/3 "2023-12-22T08:35:37Z")

</div>

Thank you very much for your suggestion. I have tested this approach, and under the release configuration, the number of DLLs has decreased from 160 to 80.  
This is a significant improvement. I will continue to explore the CMake configuration to see if further streamlining is possible.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [December 22, 2023, 1:59pm UTC](https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948/4 "2023-12-22T13:59:49Z")

</div>

I would start by setting modules that you don’t need with `-DVTK_MODULE_ENABLE_VTK_XYZ=DONT_WANT`. That will make it not build if nothing else requires it but not block something needing it from turning it on.

---

<div class="post-metadata">

### Author: ![WangZP10969](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wangzp10969/32/2579_2.png) [@WangZP10969](https://discourse.vtk.org/u/WangZP10969)
#### Post date: [December 23, 2023, 7:09am UTC](https://discourse.vtk.org/t/is-there-a-way-to-compile-the-vtk-to-a-single-dll/12948/5 "2023-12-23T07:09:41Z")

</div>

That’s good advice, I’ll check it out.  
However, the exe I generated required more than half of the DLLs to be called, which was still more than I expected.
