Linking debug C++ DLL with python dlls

moshehaim1 at gmail.com moshehaim1 at gmail.com
Thu Nov 8 07:07:47 EST 2007


Hi,

I am working with C++ code that needs to be maintained both in debug
and release versions. The environment is Windows 32 bit with MSVC8.

I downloaded the python installation for Win32 and installed it.
When, however, I tried to compile my DLLs in debug mode i got link
errors specifying that I need the python25_d.lib.

this is the code that generates the dependency on the python25_d.lib
in the <pyconfig.h>
#ifdef MS_COREDLL
#	ifndef Py_BUILD_CORE /* 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.) */
#			ifdef _DEBUG
#				pragma comment(lib,"python25_d.lib")
#			else
#				pragma comment(lib,"python25.lib")
#			endif /* _DEBUG */
#		endif /* _MSC_VER */
#	endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

So I decided to download and build the debug version of python2.5.1/
As it seems I also need to compile all relevant extension modules
(*.pyd) in debug as well - is this correct?

I tried to change the code above (just for fun) so in both cases i'll
use python25.lib and in debug compilation I got linker errors on
unresolved externals. seems like the debug version exports more
methods than the release version.

Is there a way to have my C++ code compile in debug mode (with _DEBUG)
but use the python25 release lib/dll? This way I don't need to have
additional set of debug extension modules.

Thanks,
Moshe.




More information about the Python-list mailing list