visual-studio - 到哪里找python34_d.lib这个文件?

 POPO炮炮_797 发布于 2022-11-03 12:40

我自己写了一个例子,用C语言调用Python。
但是我在编译的时候发现,如果是Debug模式的话,会需要python34_d.lib这个文件(当然,如果是Release模式的话,需要的是python34.lib这个文件)。

我找了官方发布的资源,并没有python34_d.lib这个文件。所以问下去哪里能够找到?

我觉得,作为一个非Python核心开发者,我肯定不需要自己编一个debug版的python来调试。所以我觉得官方应该有这个资源吧?
当然,也有可能有办法关闭这个选项。


这个是我写的C语言调用python的例子:

#include 
#include 
#include 

int main(int argc, char* argv[])
{
    PyObject* sys;
    Py_Initialize();
    sys = PyImport_ImportModule("sys");
    PyObject* version = PyObject_GetAttrString(sys, "version");
    printf("%s\n", PyUnicode_AsUTF8(version));
    Py_Finalize();
    return 0;
}

因为%PythonInstallPath%/include/pyconfig.h中的如下片段,所以需要python34_d.lib文件:

/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#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.) */
#           if defined(_DEBUG)
#               pragma comment(lib,"python34_d.lib")
#           elif defined(Py_LIMITED_API)
#               pragma comment(lib,"python3.lib")
#           else
#               pragma comment(lib,"python34.lib")
#           endif /* _DEBUG */
#       endif /* _MSC_VER */
#   endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

最后,这个是我的测试环境:
Windows8.1 64位,Visual Studio Express 2013,Python 3.4.2 64位。

3 个回答
  • 装个最新的 PTVS 插件

    居然还被踩,我r

    2022-11-05 18:43 回答
  • 不是很简单吗?我也找不到,吧“pyconfig.h"的文件改了:
    if defined(_DEBUG)

    pragma comment(lib,"python34.lib")

    就行了。

    2022-11-05 18:53 回答
  • 你得用VS编译一份DEBUG版的python。

    2022-11-05 18:53 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有