Complie 9.2.6 Debug under Windows

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:

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

Hello,

Please, go through the following checklist: Linker Tools Error LNK1104 | Microsoft Learn

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

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

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

  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”

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

image

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

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 If VS2013, for example, was used to build Python, you will very likely have problems compiling with VS2022.

best,

PC

Python has “autolinking” which injects these kinds of things. There’s a PR to disable this but it’s probably destined for 3.13 at this point.

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

I will try:

add_compile_definitions(PY_NO_LINK_LIB)

and report back the result.

Thanks,

Andrea

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…

That PR has yet to be merged, so…

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