本文记录如何在windows下编译pjsip,包括pjsua和pjsua2的python模块。

1,安装mingw

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

2,在mingw中安装:msys-base,mingw32-gcc,mingw32-gcc-g++和mingw32-libz

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

把mingw的bin目录(如C:\MinGW\bin)添加到系统环境变量path

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

3,解压pjsip2.3.0,在pjsip目录下(如D:\pjproject-2.3\pjlib\include\pj)创建config_site.h

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

4,创建msys目录下的fstab文件(如C:\MinGW\msys\1.0\etc),添加内容:如d:/pjproject-2.3 /pjsip

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

5,启动msys.bat
cd /pjsip
./configure
make dep
make

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

6,安装pjsua
安装python2.7.7

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

将python目录(如C:\Python27)添加到系统环境变量path

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

cd /pjsip/pjsip-apps/src/python
python setup.py build_ext --compiler=mingw32 install

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

7,安装pjsua2
下载swig,将swig目录(如D:\swigwin-3.0.2)添加到系统环境变量path

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

cd /pjsip/pjsip-apps/src/swig
make
make install

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

8,测试安装是否成功
在cmd里启动python,输入:
import pjsua
import pjsua2

complie pjsip and pjsua and pjsua2 on windows with mingw-LMLPHP

注1:修改完系统环境变量path后,要重新打开msys
注2:相关下载
mingw: http://sourceforge.net/projects/mingw/files/
pjsip: http://www.pjsip.org/release/2.3/pjproject-2.3.zip
python: https://www.python.org/ftp/python/2.7.7/python-2.7.7.msi
swig: http://prdownloads.sourceforge.net/swig/swigwin-3.0.2.zip

10-03 22:25