C++调用Python脚本遇到的问题记录《后续还会添加 方便查阅》

来源:互联网 发布:淘宝网搜索排名规则 编辑:程序博客网 时间:2024/04/29 20:45


在vs 2013 下 debug 模式出现链接问题 例如:

extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function _PySwigObject_format

这主要是因为 Py_DEBUG/Py_TRACE_REFS 引起, 修改 Python\include 下的 pyconfig.h, object.h 两个文件就行了。

1. 修改 pyconfig.h

修改

#ifdef _DEBUG

# define Py_DEBUG

#endif

#ifdef _DEBUG

//# define Py_DEBUG

#endif

 

修改

# ifdef _DEBUG

# pragma comment(lib,"python24_d.lib")

# else

# pragma comment(lib,"python24.lib")

# endif

# ifdef _DEBUG

# pragma comment(lib,"python24.lib")

# else

# pragma comment(lib,"python24.lib")

# endif

 

2. object.h

修改

#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)

#define Py_TRACE_REFS

#endif

#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)

// #define Py_TRACE_REFS

#endif

0 0
原创粉丝点击