使用MSVC上定义的DEBUG编译python模块 [英] Compiling python modules with DEBUG defined on MSVC

查看:134
本文介绍了使用MSVC上定义的DEBUG编译python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python愚蠢地在其include文件中有一个pragma指令,当 DEBUG python26_d.lib 的链接>定义了预处理程序变量。这是一个问题,因为python安装程序没有随附 python26_d.lib !因此,我无法在MSVC中以调试模式构建应用程序。如果我仅对一个文件临时 #undef DEBUG ,我会收到很多有关DLL链接不一致的投诉。如果我更改python包含文件中的编译指示,则会得到未定义的对各种调试函数的引用。

Python rather stupidly has a pragma directive in its include files that forces a link against python26_d.lib when the DEBUG preprocessor variable is defined. This is a problem because the python installer doesn't come with python26_d.lib! So I can't build applications in MSVC in debug mode. If I temporarily #undef DEBUG for just one file I get many complaints about inconsistent DLL linkage. If I change the pragma in pythons include file I get undefined references to various debug functions.

我尝试编译自己的python版本,但它与python有所不同

I have tried compiling my own version of python but its somehow different enough from the python that gets distributed that I can't use my modules with apps built with the vanilla version of python

有人可以给我任何有关如何解决这个问题的建议吗?

Can anyone give me any advice on how to get round this?

推荐答案

来自 Python列表


作为一种解决方法,请尝试
将文件python26.dll复制到
python26_d.dll。 (我不确定这
是否会工作;您说您是在调试模式下构建
SWIG库,SWIG可能会尝试使用

功能) Python调试
版本。如果是这种情况,您将
别无选择,只能使用Python的
调试版本。)

As a workaround to the situation, try to copy the file python26.dll to python26_d.dll. (I'm not sure this will work; you say you are building a SWIG library in debug mode, and it's possible that SWIG will try to use features of the Python debugging version. If that's the case, you'll have no choice but to use the debugging version of Python.)

编辑:从注释:


您还应该编辑pyconfig.h和
注释在 #define
Py_DEBUG行(第374行)

You should also edit pyconfig.h and comment out the line "#define Py_DEBUG" (line 374)

这篇关于使用MSVC上定义的DEBUG编译python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆