I’ve been building Slicer for a long while using the same scripts. I’ve updated to the latest Slicer main version (from a version maybe a few weeks ago), started a clean build from scratch (removed all build folders) and this latest version does not build due to python312_d.lib is not found when linking qSlicerBaseQTCore.
The only mentions of python312_d.lib in any files in all build folders:
In Python-3.12.10/PC/pyconfig.h, python-build/bin/Release/PC/pyconfig.h, and python-install\include\pyconfig.h:
...
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
# if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
/* not building the core - must be an ext */
# if defined(_MSC_VER)
/* So MSVC users need not specify the .lib
file in their Makefile (other compilers are
generally taken care of by distutils.) */
# if defined(_DEBUG)
# pragma comment(lib,"python312_d.lib")
# elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
# else
# pragma comment(lib,"python312.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */
...
In Slicer-build\Base\QTCore\qSlicerBaseQTCore.dir\Debug\qSlicerCoreApplication.obj:
/DEFAULTLIB:"python312_d.lib"
Modifying the pyconfig.h files from:
# pragma comment(lib,"python312_d.lib")
to
# pragma comment(lib,"python312.lib")
resolves the build problem, so something may have changed in how pyconfig.h is included or in MS_COREDLL, Py_BUILD_CORE, Py_BUILD_CORE_BUILTIN, _MSC_VER, or _DEBUG defines.
For the record I have the very same problem with the latest version. We cannot really debug Slicer until this is solved, so unless everyone is on vacation, please try to chime in Thanks a lot!
do you want to just patch the source? there is already a pythonapplypatches.cmake.
Is there still a reason to just use the release library still on windows? it is change from 2013 i guess the cmake python build is that still case? ef28720
Yes, just change the source (single line of change) and everything works. It is a very quick and easy workaround but of course it should be fixed properly.
@jcfr please have a look at this when you have time.
Is there still a reason to just use the release library still on windows?
The motivation for this is the same as before. When we build the application in Debug mode, we almost always do that to debug the Slicer application or extensions; and not to debug implementation of low-level libraries such as CPython. Building Python in Release mode allows us to have much better Python runtime performance.