7

windos10环境下编译python3版pjsua库

 2 years ago
source link: https://www.cnblogs.com/MikeZhang/p/win10py3pjsua-20211010.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

环境:
windows10_x64
python3.9_x64
pjsua-2.10
vs2015

pjsua编译参考这里: https://www.cnblogs.com/MikeZhang/p/pjsip20210116.html

pjsua默认绑定的python版本是python 2.4,使用起来有诸多限制,希望可以使用python3调用pjsua的库实现软电话的基础功能。

编译python_pjsua

1、替换代码
官方给的代码不支持python3,需要使用第三方代码:
https://github.com/mgwilliams/python3-pjsip.git
下载之后,替换该目录 pjsip-apps/src/python
2、修改配置
为防止后续报错,打开 pjsip-apps\src\python\_pjsua.def文件,将init_pjsua改为PyInit__pjsua
3、添加python3编译依赖
打开项目选择,python_pjsua 右键-属性

添加include路径

添加lib依赖

修改依赖项 python24.lib 为python39.lib

4、如果报错LNK1112: 模块计算机类型“x64”与目标计算机类型“x86”冲突

修改链接器里面的Target Machine为X64,需要注意同步修改依赖。

5、添加额外lib库,防止链接出错
文件 : _pjsua.c
添加代码:
#pragma comment(lib, "msvcrtd.lib")
#pragma comment(lib, "vcruntimed.lib")
#pragma comment(lib, "ucrtd.lib")
#pragma comment(lib, "ole32.lib")

6、执行编译

成功后再pjsip-apps/lib目录下有_pjsua.pyd文件,将其与pjsip-apps/src/python/pjsua.py文件一起放到python3.9 目录下/Lib/site-packages目录下
或者放在需要引用的目录里面

 8、相关资源

 python3.9_x64

python3-pjsua.7z

源码及预编译文件

本文涉及完整代码及资源下载地址:

https://pan.baidu.com/s/1n3xcEIZYtPQt9cv70Loffw

可关注微信公众号(聊聊博文)后回复 2021101001 获得提取码。 


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK