# Would like to compile the ITK without external third-party libraries

**URL:** https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632
**Category:** Engineering
**Created:** [September 18, 2025, 1:56am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632 "2025-09-18T01:56:59Z")
**Posts on this page:** 16
**Page:** 2

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 30, 2025, 1:59pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/21 "2025-09-30T13:59:02Z")

</div>

I can reproduce this locally with `main` branch. I am taking a look.

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [September 30, 2025, 2:08pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/22 "2025-09-30T14:08:17Z")

</div>

Released version 5.4.4. By the way, the download link of 5.4.4 seems wrong, I can only get version 5.4.3 through the download page.

—Original—

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 30, 2025, 2:21pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/23 "2025-09-30T14:21:01Z")

</div>

@matt.mccormick I think we need to regenerate the documentation. The link change was made in [PR 5519](https://github.com/InsightSoftwareConsortium/ITK/pull/5519).

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 30, 2025, 4:21pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/24 "2025-09-30T16:21:08Z")

</div>

Turning on `Module_IOTransformDCMTK` triggers the compile time error in `ITKIODCMTK`. We don’t even get to [issue 2872](https://github.com/InsightSoftwareConsortium/ITK/issues/2872).

`CMAKE_CXX_STANDARD` isn’t the only thing that does not propagate properly. PNG, ZLIB, and TIFF specifications [here](https://github.com/InsightSoftwareConsortium/ITK/blob/71225e30a5b09afa02d7e06eeecd605d313437a4/Modules/ThirdParty/DCMTK/CMakeLists.txt#L321-L326) don’t get picked up [here](https://github.com/InsightSoftwareConsortium/DCMTK/blob/8197ee21a2e17be65b72508dca9a91d4d60725aa/CMake/3rdparty.cmake#L27-L155) due to [missing DCMTK\_USE\_FIND\_PACKAGE](https://github.com/InsightSoftwareConsortium/ITK/pull/5537).

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 30, 2025, 4:26pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/25 "2025-09-30T16:26:58Z")

</div>

Also entered to the bug tracker as [issue 5539](https://github.com/InsightSoftwareConsortium/ITK/issues/5539).

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [October 1, 2025, 4:17am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/26 "2025-10-01T04:17:10Z")

</div>

> I think we need to regenerate the documentation. The link change was made in PR 5519.

The documentation builds were updated to build from `main` instead of `master` and now have the updated links.

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [October 9, 2025, 5:47am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/27 "2025-10-09T05:47:09Z")

</div>

Then how could I deal with the error of Google Test. I’ve noticed that

> ITKGoogleTest is needed by [ITKImageIntensity-Test;ITKLabelMap-Test;BoneEnhancement-Test;SimpleITKFilters-Test;TextureFeatures-Test;ITKSuperPixel-Test;ITKGroup\_ThirdParty].

I still need to retain these tests so that I can verify every module.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 9, 2025, 1:22pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/28 "2025-10-09T13:22:34Z")

</div>

Some of the tests are written as GTests. They cannot be compiled without Google Test. We do not make distinction between GTest-based unit tests and other unit tests. No one needed that feature before. If you need that feature so much, you could contribute it. Namely, make compilation of GTest-based unit tests conditionally enabled, only when GTest is turned on. That will entail mostly, if not exclusively, CMake code changes.

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [October 10, 2025, 4:08am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/29 "2025-10-10T04:08:23Z")

</div>

I see. But there seems be two targets named “gtest”, and conflict when “add\_library”. But if I change it to add library only when there is not target “GTEST\_LIBRARY”, the building program cannot find the gtest.h file, as I mentioned before. I think some path needs to be changed so that the program can locate gtest.h properly.

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [October 16, 2025, 10:38am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/30 "2025-10-16T10:38:37Z")

</div>

Hi,

I’m trying to compile ITKCommon as dynamic library and keep other modules static, but module dependency checks will enable ITKCommon and compile static library. I attempt to skip the dependency check, but it cannot link with the ITKCommon dynamic lib. Could you please give me some advice?

Rosie

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 16, 2025, 2:51pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/31 "2025-10-16T14:51:03Z")

</div>

I am not sure that anyone wanted this before. I expect that non-trivial CMake code changes will be required in ITK. Possibly some major changes. I advise against trying this. Pick either ITK to be all dynamic or all static libraries. Either of those choices should work well.

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [October 16, 2025, 5:56pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/32 "2025-10-16T17:56:25Z")

</div>

It’s because ITKCommon static library is too large and will occupy a lot of memory when in use.

—Original—

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [October 23, 2025, 10:46am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/33 "2025-10-23T10:46:59Z")

</div>

Hi **[dzenanz](https://discourse.itk.org/u/dzenanz),**

Thank you very much for your support.

We decided to use shared library but need to **add a prefix** in the output target to avoid version conflict. So I add:

#change ITK target name  
set\_target\_properties(${\_name} PROPERTIES  
OUTPUT\_NAME “Q${\_name}”  
ARCHIVE\_OUTPUT\_NAME “Q${\_name}”  
RUNTIME\_OUTPUT\_NAME “Q${\_name}”  
LIBRARY\_OUTPUT\_NAME “Q${\_name}”  
)

in macro(itk\_module\_add\_library \_name) of ITKModuleMacros.cmake file. The names of some modules are changed, and some are not. I wonder if there could be something else that need to be modified? I guess it could be possible as each target has a version suffix.

cheers,  
Rosie

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 23, 2025, 1:01pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/34 "2025-10-23T13:01:29Z")

</div>

Maybe it would be helpful to take a look at [this commit](https://github.com/Slicer/ITK/commit/57883d5331f9749e7445fa790f09d86f735c7aa9) from [this branch](https://github.com/Slicer/ITK/commits/slicer-v5.4.4-2025-06-11-f98d5fa/) of Slicer’s fork of ITK. Its purpose is different, but might provide further inspiration.

Also, @blowekamp or someone else from SimpleITK team might have suggestions about change on-disk library names.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [October 23, 2025, 1:47pm UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/35 "2025-10-23T13:47:54Z")

</div>

> [@Rosie](#):
>
> It’s because ITKCommon static library is too large and will occupy a lot of memory when in use.

This does not source correct to me. A static library is not used during a run-time application, it use used by a linker to create shared libraries and executables. Depending on what parts of the library used and optimization to resolve duplicate symbols done, can effect the size of the linked binaries.

> [@Rosie](#):
>
> We decided to use shared library but need to **add a prefix** in the output target to avoid version conflict.

There are more issues to address then conflicting shared libraries names. All of the symbols use by the library and third party libraries need to not conflict and/or resolve correctly. These are difficult tasks.

The SimpleITK approach is to compile all of ITK as static libraries, and hide all the symbols of ITK, and ITK’s third party libraries. These are then linked into the SimpleITK libraries, which only expose the SimpleITK symbols.

---

<div class="post-metadata">

### Author: ![Rosie](https://discourse.itk.org/user_avatar/discourse.itk.org/rosie/32/4585_2.png) [@Rosie](https://discourse.itk.org/u/Rosie)
#### Post date: [October 24, 2025, 8:14am UTC](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632/36 "2025-10-24T08:14:22Z")

</div>

Thank you so much. Today I’ve tried to modify the end of the macro(itk\_module\_target\_name \_name) in theITKModuleMacros.cmake file.

> #change ITK target name  
> set(\_Q\_prefix “Q”)  
> set\_property(TARGET ${\_name} PROPERTY OUTPUT\_NAME ${\_Q\_prefix}${\_itk}${\_name}${\_lib\_suffix})

The target names change as I supposed. I’ll test them in my applications in case any conflict.

[Previous page](https://discourse.itk.org/t/would-like-to-compile-the-itk-without-external-third-party-libraries/7632.md?page=1)
