pjsip的python扩展使用

1. 在vs2005中编译python_pjsua项目会有下列错误(python2.7)

   Creating library ./output/python_pjsua-i386-win32-vc8-debug/_pjsua_d.lib and object ./output/python_pjsua-i386-win32-vc8-debug/_pjsua_d.exp
_pjsua.obj : error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function _PyObj_pjsip_cred_info_delete
_pjsua.obj : error LNK2019: unresolved external symbol __imp___Py_NegativeRefcount referenced in function _PyObj_pjsip_cred_info_delete
_pjsua.obj : error LNK2001: unresolved external symbol __imp___Py_RefTotal
_pjsua.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function _init_pjsua
../lib/_pjsua_d.pyd : fatal error LNK1120: 4 unresolved externals

主要是因为 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 /* _DEBUG */

# ifdef _DEBUG
# pragma comment(lib,"python24.lib")
# else
# pragma comment(lib,"python24.lib")
# endif /* _DEBUG */
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

但主要也是在Debug模式下出问题,可以选为release版的

你可能感兴趣的:(pjsip的python扩展使用)