gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 20:32:34 26 4
gpt4 key购买 nike

Python 相当愚蠢地在其包含文件中有一个 pragma 指令,当定义 DEBUG 预处理器变量时,它会强制链接到 python26_d.lib。这是一个问题,因为 python 安装程序没有附带 python26_d.lib!所以我不能在 Debug模式下在 MSVC 中构建应用程序。如果我只为一个文件临时 #undef DEBUG 我会收到很多关于不一致的 DLL 链接的投诉。如果我更改 pythons 包含文件中的编译指示,我会得到对各种调试函数的 undefined reference 。

我已经尝试编译我自己的 python 版本,但它与分发的 python 有很大的不同,我无法将我的模块与使用普通版 python 构建的应用程序一起使用

谁能给我任何关于如何解决这个问题的建议?

最佳答案

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

编辑:来自评论:

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

关于python - 使用 MSVC 上定义的 DEBUG 编译 python 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1236060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com