使用MSVC上定义的DEBUG编译python模块

编程入门 行业动态 更新时间:2024-10-27 05:22:06
本文介绍了使用MSVC上定义的DEBUG编译python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Python愚蠢地在其include文件中有一个pragma指令,当 DEBUG 定义了预处理程序变量。这是一个问题,因为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模块

本文发布于:2023-11-13 11:56:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   定义   MSVC   python   DEBUG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!