How to build PJSUA2 (swig) with Visual Studio 2015

社会主义新天地 提交于 2019-12-05 22:05:18

I could make a workaround to compile pjsua2 for Python 3.7. If you have a better solution or just suggestion to this workaround, let me know

Preconditions:

  • List item
  • Download and extract swig (swigwin 4.0.0)
  • Download and install JDK
  • Download and install Python (Python 3.7.3 x64) and set at custom installation:
    • tick "Add Python to environment variables"
    • tick "Precompile standard library"
    • tick "Download debugging symbols"
    • tick "Download debug binaries (requires VS 2015 or later)"
    • set custom path if you want
    • add swigwin location to system path
    • add Python location to system path
    • add JAVA_HOME system variable
    • add %JAVA_HOME%\bin to system path
    • Install Visual Studio 2015 Community edition

Steps:

  • Download and extract pjsip 2.8
  • Create empty config_site.h under pjlib/inlclude/pj/ folder
  • Open pjproject-vs14.sln in VS
  • There will be an unsupported warning window, press OK
  • At the "Install Missing Features" windows, press install
  • VS installer will be started, and VS has to be closed to complete installation.
  • I have also added "Windows 10 SDK (10.0.10586)" to the installation.
  • I have also enabled developer mode on my Windows 10, but this could be optional
  • Open project again in VS
  • Set project to Release and x64 on the top dropdown
  • Right click on the solution, and go to Configuration Properties> Configuration
  • Remove all uwp and wp8 related projects from selection, like pjsua_cli_uwp_comp, pjsua_cli_wp8_comp
  • press OK, and build solution
  • I have had 34 succeeded and 0 failed solution after build.
  • Add following lines to pjsua2.i in pjsip-apps/src/swig folder

    %inline %{
    pj_ssize_t new_pj_ssize_t(int s) {
       return (pj_ssize_t) s;
    }
    %}
    

    this extra inline swig function provides workaround for create recorder issue

  • Open a command line (powershell did not work for this)
  • go to pjsip-apps/src/swig/python
  • Execute following command:

    swig -I../../../../pjlib/include -I../../../../pjlib-util/include -I../../../../pjmedia/include -I../../../../pjsip/include -I../../../../pjnath/include -py3 -c++  -python -threads ../pjsua2.i
    
  • Add new "Empty Project" (Visual C++) to solution with swig_python_pjsua2 name

  • Add libpjproject and pjsua2_lib as reference to this new project
  • Right click on the Header Files>Add>Existing Item...
  • Add pjsip-apps\src\swig\pjsua2_wrapp.h
  • Add a "new filter" to the project with name "Generated Code"
  • Right click on "Generated code" and add new existing item.
  • Add pjsip-apps\src\swig\pjsua2_wrapp.cxx
  • Right click on the project and Linker>Input
  • Add "Ws2_32.Lib" to "Additional Dependencies"
  • Go to "VC++ Directories"
  • Add following folder to include path(I have used full path!):
    • c:\python37\include
    • pjnath\include
    • pjsip\include
    • pjmedia\include
    • pjlib-util\include
    • pjlib\include
  • Add following folder to Library Directories:
    • C:\Python36\libs
  • Set at General:
    • Target Name: _$(ProjectName)
    • Target Extension: .pyd
    • Configuration Type: Dynamic Library (.dll)
  • Go to properties of the solution, and select swig_python_pjsua2 to build
  • Right click on swig_python_pjsua2 and build
  • Build should complete successfully
  • You will need to file to use pjsua2 library in python.
  • pjsua.py located under pjsip-apps/src/swig/python
  • x64/Release/_swig_python_pjsua2.pyd (rename this to _pjsua2.pyd)
  • To test, copy those to file into a folder, start python from same folder and type:
    • import pjsua2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!