# Windows debug build and python library

**URL:** <https://discourse.slicer.org/t/windows-debug-build-and-python-library/12207>\
**Category:** Development\
**Created:** [June 24, 2020, 10:33pm UTC](https://discourse.slicer.org/t/windows-debug-build-and-python-library/12207 "2020-06-24T22:33:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![finetjul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/finetjul/32/146_2.png) [@finetjul](https://discourse.slicer.org/u/finetjul)\
**Post date:** [June 24, 2020, 10:33pm UTC](https://discourse.slicer.org/t/windows-debug-build-and-python-library/12207/1 "2020-06-24T22:33:22Z")

</div>

Hi all,

What is the status with debug build of Slicer on Windows ? I am trying to build Slicer master (without SimpleITK) on MSVC2017 x64 in Debug with no luck.  
I saw some recent changes from @lassoan. e.g. [49f3f0b8](https://github.com/Slicer/Slicer/commit/49f3f0b8c02621baf6bad4e98c0b45c2ef30cd52).

As I am about to stop trying, I would like to share with you my findings:

> **I have these kinds of warnings...**
>
> ```
> CMake Warning (dev) at C:/Work/R-b/vtkAddon/CMake/vtkMacroKitPythonWrap.cmake:242 (target_link_libraries):
> Link library type specifier "optimized" is followed by specifier
> "optimized" instead of a library name. The first specifier will be ignored.
> Call Stack (most recent call first):
> C:/Work/R-b/vtkAddon/CMakeLists.txt:206 (vtkMacroKitPythonWrap)
> This warning is for project developers. Use -Wno-dev to suppress it.
> 
> ```

> **and these kinds of errors...**
>
> ```
> 1>CMake Error at C:/Work/R-b/slicersources-src/CMake/SlicerMacroBuildApplication.cmake:462 (get_filename_component):
> get_filename_component unknown component
> C:/Work/R-b/python-install/libs/python36.lib
> Call Stack (most recent call first):
> C:/Work/RFC/RFCo/Src/rfviewer/Applications/RFViewerApp/CMakeLists.txt:87 (slicerMacroBuildApplication)
> 
> ```

This is because the variable `PYTHON_LIBRARY` is equal to:  
`optimized;C:/Work/R-b/python-install/libs/python36.lib;debug;C:/Work/Python/Python36/libs/python36_d.lib`

According to the following 3 interesting links…  
[https://cmake.org/pipermail/cmake/2016-April/063150.html](https://cmake.org/pipermail/cmake/2016-April/063150.html)  
[https://github.com/Slicer/VTK/pull/24](https://github.com/Slicer/VTK/pull/24)  
[https://gitlab.kitware.com/cmake/cmake/-/commit/a12d8a03af8430d0a570c97deb200e16830568eb](https://gitlab.kitware.com/cmake/cmake/-/commit/a12d8a03af8430d0a570c97deb200e16830568eb)

… it seems (at least according to the last commit message) that it is ok to have `PYTHON_LIBRARY=optimized;...;debug;...`

Do you confirm ? Therefore should the fix done on `FindPythonLibs` be applied everywhere ? If so, what about the warnings ? And what about the erroneous debug python path found on system ?

For information, when configuring `Slicer/CMakeLists.txt` (inner build, not superbuild), it seems that `PYTHON_LIBRARY` is fine (i.e. `C:/Work/R-b/python-install/libs/python36.lib`) until `find_package(CTK REQUIRED)` is called. It is then equal to `optimized;...;debug;...`

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 24, 2020, 10:55pm UTC](https://discourse.slicer.org/t/windows-debug-build-and-python-library/12207/2 "2020-06-24T22:55:11Z")

</div>

Thanks for the detailed report 🙏

Could you try with this patch applied to CTK: [https://github.com/commontk/CTK/pull/901](https://github.com/commontk/CTK/pull/901) ?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 24, 2020, 10:57pm UTC](https://discourse.slicer.org/t/windows-debug-build-and-python-library/12207/3 "2020-06-24T22:57:10Z")

</div>

The PR referenced above will be integrated while finalizing the update to VTK9 (tracked in [https://github.com/Slicer/Slicer/issues/4696](https://github.com/Slicer/Slicer/issues/4696))

I expect to work on this in the next t weeks.
