# Complie 9.2.6 Debug under Windows

**URL:** https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234
**Category:** Support
**Created:** [April 17, 2023, 9:44pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234 "2023-04-17T21:44:26Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![aborsic](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@aborsic](https://discourse.vtk.org/u/aborsic)
#### Post date: [April 17, 2023, 9:44pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/1 "2023-04-17T21:44:26Z")

</div>

Hi All,

I am trying to compile VTK 9.2.6 under Windows using Visual Studio 2022, CMake 3.25.2 and Python 3.11.2 for bindings. The release compile succeeds, but the debug fails with this error:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/d/da0ff8a7925616653eeb894a7ccdbf35d317c77c.png)

I am puzzled as: 1) the debug compile should look for python311\_d.lib 2) python311.lib is in any case present under C:\Python311\libs on my system.

I have tried looking at the properties of the Debug configuration in Visual Studio, and the IDE does not show any “python311.lib” in the command line passed to the linker.

Does anyone have any suggestion or have experienced the same?

Thanks,

Andrea

---

<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: [April 18, 2023, 11:04am UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/2 "2023-04-18T11:04:47Z")

</div>

Hello,

Please, go through the following checklist: [Linker Tools Error LNK1104 | Microsoft Learn](https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1104?view=msvc-170)

That error can have a multitude of causes. The mere existence of the file does not necessarily mean the build will be successful.

> [@aborsic](#):
>
> 1. the debug compile should look for python311\_d.lib

Do you have it? If not, the build script may be falling back to the release version. Furthermore, the name of the debug link-time libraries may not end with `_d`. I’ve seen just `d` for example. The exact name depends on the build script (are you using `nmake`?).

take care,

PC

---

<div class="post-metadata">

### Author: ![aborsic](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@aborsic](https://discourse.vtk.org/u/aborsic)
#### Post date: [April 19, 2023, 1:54pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/3 "2023-04-19T13:54:46Z")

</div>

Hi Paulo,

Thanks for your message. Still not solved the issue and puzzled by it.

These are some facts and considerations:

1. I am compiling the project from within the Visual Studio IDE by manually selecting build. The Release configuration compiles OK, the Debug does not.

2. The release and debug Python libraries are in place and CMAKE should have pointed to them correctly, as otherwise the release compile should fail (below a picture of the contents of the libs subdir of the python interpreter

 ![Libraries](https://discourse.vtk.org/uploads/default/original/2X/9/945c19e493ad8a9abb6b57259175855d0299fbac.png)

1. By looking at the properties of the WrappingPyhtonCore project in VisualStudio for the Debug configuration, it looks like that it is pointing to the right library path “C:\Python311\libs\python311\_d.lib” and at the debug version of the library “python311\_d.lib”

 ![Dependancies](https://discourse.vtk.org/uploads/default/original/2X/e/e7b85571cfbaffa398350faa69db3b34daa69e6d.png)

1. The link error though refers to a missing python311.lib

![image](https://discourse.vtk.org/uploads/default/original/2X/7/721d102b3a847045aa06085f17edc539f04590fc.png)

This is puzzling, as: 1) the project configuration is linking against the debug library python311\_d.lib 2) in any case, the release library python311.lib is present in the same folder as the debug library, and so one of the two should be found.

–

I did not find any Debug build in the VTK dashboard. Has anyone tried building a Debug version of VTK 9.2.6 on Windows with wrapping for Python 3.11?

Thanks for any feedback,

Andrea

---

<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: [April 19, 2023, 2:16pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/4 "2023-04-19T14:16:17Z")

</div>

Hello,

I you went through **all** that checklist and nothing solved it, you should make sure VS2022 is compatible with whatever version of VS was used to generate those `.lib` files. VS compilers are not always retro-compatible. Check this: [C++ binary compatibility 2015-2022 | Microsoft Learn](https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=msvc-170) If VS2013, for example, was used to build Python, you will very likely have problems compiling with VS2022.

best,

PC

---

<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: [April 24, 2023, 3:33am UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/5 "2023-04-24T03:33:00Z")

</div>

Python has “autolinking” which injects these kinds of things. There’s [a PR to disable this](https://github.com/python/cpython/pull/19740) but it’s probably destined for 3.13 at this point.

---

<div class="post-metadata">

### Author: ![aborsic](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@aborsic](https://discourse.vtk.org/u/aborsic)
#### Post date: [April 24, 2023, 8:51am UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/6 "2023-04-24T08:51:11Z")

</div>

Hi Ben,

Thanks for the note: do I interpret it correctly that I should not expect VTK with Python bindings to Python 3.11 to compile correctly, for example for the debug version? I have looked at the dashboard and there seem not to be any debug version there. Has anyone at VTK tried compiling VTK with Python 3.11 bindings / debug under Windows?

Thanks for any information,

Best Regards,

Andrea

---

<div class="post-metadata">

### Author: ![aborsic](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@aborsic](https://discourse.vtk.org/u/aborsic)
#### Post date: [April 24, 2023, 8:57am UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/7 "2023-04-24T08:57:53Z")

</div>

I will try:

add\_compile\_definitions(PY\_NO\_LINK\_LIB)

and report back the result.

Thanks,

Andrea

---

<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: [April 24, 2023, 5:10pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/8 "2023-04-24T17:10:51Z")

</div>

> [@aborsic](#):
>
> Has anyone at VTK tried compiling VTK with Python 3.11 bindings / debug under Windows?

It’s been attempted, but it’s certainly not the norm, no. Are you trying to debug Python itself or do you just want VTK to be `Debug`? It _should_ work to compile that against a non-debug Python…

> [@aborsic](#):
>
> add\_compile\_definitions(PY\_NO\_LINK\_LIB)

That PR has yet to be merged, so…

---

<div class="post-metadata">

### Author: ![aborsic](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ed655f/32.png) [@aborsic](https://discourse.vtk.org/u/aborsic)
#### Post date: [April 24, 2023, 8:02pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/9 "2023-04-24T20:02:30Z")

</div>

I need to debug an external project. I will probably simply compile a Release With Debug info of the external project so it should link to the Release version of VTK. I should be all set with this, as I do not need to put breakpoints or follow the execution within VTK sources.

Thank you for the help !

Andrea

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [October 6, 2024, 9:50pm UTC](https://discourse.vtk.org/t/complie-9-2-6-debug-under-windows/11234/10 "2024-10-06T21:50:41Z")

</div>

@aborsic Did you solve this. For other projects, I do this

```auto
if (MSVC)
  string(REPLACE "_d" "" Python3_LIBRARIES "${Python3_LIBRARIES}")
endif()

set(TEMP_CMAKE_DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
unset(CMAKE_DEBUG_POSTFIX)
swig_add_library(swig_Geometry
  TYPE SHARED
  LANGUAGE python
  SOURCES swig_Geometry.i)
set(CMAKE_DEBUG_POSTFIX ${TEMP_CMAKE_DEBUG_POSTFIX})

```

It works, out of the box, but it requires me to change the `.cmake` files of VTK.
