通过在MSVC上定义的DEBUG来编译python模块

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

如果 DEBUG 预处理器变量被定义。这是一个问题,因为python安装程序不会附带 python26_d.lib !所以我无法在调试模式下以msvc构建应用程序。如果我暂时只有一个文件 #undef DEBUG ,我会得到很多关于DLL链接不一致的投诉。如果我改变pythons中的pragma包含文件我得到未定义的引用到各种调试功能。

我已经尝试编译我自己的版本的python,但它有点不同于python得到分发,我不能使用我的模块与使用香草版本的python构建的应用程序

任何人都可以给我任何建议如何解决这个问题? p>

谢谢

解决方案

从 python list

作为这种情况的解决方法,尝试将文件python26.dll复制到 python26_d.dll。 (我不知道这个会工作;你说你正在调试模式下建立一个 SWIG库,并且它的可能是SWIG将尝试使用的功能Python调试版本,如果是这样的话,您将别无选择,只能使用调试版本的Python。)

编辑:从评论:

你还应该编辑pyconfig.h和评论出行#define Py_DEBUG(第374行)

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.

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?

Thanks

解决方案

From python list

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.)

Edit: From comments:

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

更多推荐

通过在MSVC上定义的DEBUG来编译python模块

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

发布评论

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

>www.elefans.com

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