在x86 linux 平台编译 IPP版本的pjsip

发布: 2011-03-13 22:05

debian x86 5.0.x

gcc 4.3.2

ipp: /6.0.1.071 ia32

ipp-samples: 6.0.0.142

pjproject: 1.8.10



路径说明,

$HOME=/home/yourname

ipp安装在 $HOME/intel/

ipp-sample放在$HOME/ipp/下。



1. 下载并安装ipp

    下载地址, http://registrationcenter-download.intel.com/irc_nas/1326/l_ipp_ia32_p_6.0.1.071.tar.gz [^]

    申请试用31天的licence文件, https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=1453&AccountID=&EmailID=&ProgramID=&RequestDt=&rm=EVAL&lang= [^]



    解压l_ipp_ia32_p_6.0.1.071.tar.gz

    > cd l_ipp_ia32_p_6.0.1.071

    > ./install

    

    注意,这里使用非root用户安装,在注册一步,选用licence文件方式,输入申请到的licence文件路径。安装后目录结构,$HOME//intel/ipp/6.0.1.071/ia32/



2. 编译ipp-samples中的speech-codecs编码,

   下载,http://registrationcenter-download.intel.com/irc_nas/1326/l_ipp-samples_p_6.0.0.142.tgz [^]



    解压,l_ipp-samples_p_6.0.0.142.tgz

    > cd ipp-samples/speech-codecs

    > ./build32.sh



    生成库路径为_bin/linux32_gccx/



3. 设置IPPROOT, IPPSAMPLES环境变量。



   在$HOME/.bash_profile中加入:



export IPPROOT=$HOME/intel/ipp/6.0.1.071/ia32/

export IPPSAMPLES=$HOME/xfsdev/ipp/ipp-samples

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/intel/ipp/6.0.1.071/ia32/sharedlib/



   > source $HOME/.bash_profile

   > env | grep IPP



4. 编译动态链接IPP库版本的pjsip

   下载pjsip, http://www.pjsip.org/release/1.8.10/pjproject-1.8.10.tar.bz2 [^]



   解压,

   > tar xvf pjproject-1.8.10.tar.bz2

   > cd pjproject-1.8.10

   

   > vi pjlib/include/pj/config_site.h

     添加一行, #define PJMEDIA_HAS_INTEL_IPP 1



   > ./configure --enable-ipp --with-ipp=$IPPROOT --with-ipp-samples=$IPPSAMPLES

   > make

   > ldd pjsip-apps/bin/pjsua-i686-pc-linux-gnu

        linux-gate.so.1 => (0xb7f35000)

        libippsc.so.6.0 => $HOME/intel/ipp/6.0.1.071/ia32/sharedlib/libippsc.so.6.0 (0xb7f21000)

        libipps.so.6.0 => $HOME/intel/ipp/6.0.1.071/ia32/sharedlib/libipps.so.6.0 (0xb7ee1000)

        libippsr.so.6.0 => $HOME/intel/ipp/6.0.1.071/ia32/sharedlib/libippsr.so.6.0 (0xb7ec8000)

        libippcore.so.6.0 => $HOME/intel/ipp/6.0.1.071/ia32/sharedlib/libippcore.so.6.0 (0xb7ebe000)

        libguide.so => $HOME/intel/ipp/6.0.1.071/ia32/sharedlib/libguide.so (0xb7e67000)

        libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7e39000)

        libnsl.so.1 => /lib/i686/cmov/libnsl.so.1 (0xb7e20000)

        librt.so.1 => /lib/i686/cmov/librt.so.1 (0xb7e16000)

        libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7dfd000)

        libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7caa000)

        libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb7c63000)

        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7b08000)

        libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7b03000)

        libiomp5.so => $HOME/intel/ipp/6.0.1.071/ia32/sharedlib/libiomp5.so (0xb7aa5000)

        /lib/ld-linux.so.2 (0xb7f36000)

        libz.so.1 => /usr/lib/libz.so.1 (0xb7a90000)

   > ls -lh pjsip-apps/bin/pjsua-i686-pc-linux-gnu

    -rwxr-xr-x 1 test test 1.8M Dec 26 16:54 pjsip-apps/bin/pjsua-i686-pc-linux-gnu

   > ./pjsip-apps/bin/pjsua-i686-pc-linux-gnu



    在进入pjsua命令行控制台,输入 d 命令,如果显示有G729编码,则编译成功,



  Total number of installed codecs: 23

   Audio codec # 0: pt=98 (speex @16KHz/1, 27.8Kbps, 20ms vad cng plc penh)

   Audio codec # 1: pt=97 (speex @8KHz/1, 15.0Kbps, 20ms vad cng plc penh)

   Audio codec # 2: pt=99 (speex @32KHz/1, 29.6Kbps, 20ms vad cng plc penh)

   Audio codec # 3: pt=104 (iLBC @8KHz/1, 13.3Kbps, 30ms vad plc penh)

   Audio codec # 4: pt=3 (GSM @8KHz/1, 13.2Kbps, 20ms vad plc)

   Audio codec # 5: pt=0 (PCMU @8KHz/1, 64.0Kbps, 20ms vad plc)

   Audio codec # 6: pt=8 (PCMA @8KHz/1, 64.0Kbps, 20ms vad plc)

   Audio codec # 7: pt=9 (G722 @16KHz/1, 64.0Kbps, 20ms vad plc)<br />
   Audio codec # 8: pt=105 (AMR @8KHz/1, 7.4Kbps, 40ms vad cng plc)

   Audio codec # 9: pt=106 (AMR-WB @16KHz/1, 15.8Kbps, 20ms vad cng plc)

   Audio codec 0000010: pt=18 (G729 @8KHz/1, 8.0Kbps, 20ms vad cng plc)

   Audio codec 0000011: pt=4 (G723 @8KHz/1, 6.3Kbps, 30ms vad cng plc)

   Audio codec 0000012: pt=110 (G726-32 @8KHz/1, 32.0Kbps, 20ms vad cng plc)

   Audio codec 0000013: pt=2 (G721 @8KHz/1, 32.0Kbps, 20ms vad cng plc)

   Audio codec 0000014: pt=15 (G728 @8KHz/1, 16.0Kbps, 20ms vad cng plc)

   Audio codec 0000015: pt=113 (G7221 @16KHz/1, 24.0Kbps, 20ms vad cng plc)

   Audio codec 0000016: pt=114 (G7221 @16KHz/1, 32.0Kbps, 20ms vad cng plc)

   Audio codec 0000017: pt=11 (L16 @44KHz/1, 705.6Kbps, 10ms vad plc disabled)

   Audio codec 0000018: pt=10 (L16 @44KHz/2, 1.41Mbps, 10ms vad plc disabled)

   Audio codec 0000019: pt=100 (L16 @8KHz/1, 128.0Kbps, 20ms vad plc disabled)

   Audio codec 0000020: pt=101 (L16 @8KHz/2, 256.0Kbps, 20ms vad plc disabled)

   Audio codec 0000021: pt=102 (L16 @16KHz/1, 256.0Kbps, 20ms vad plc disabled)

   Audio codec 0000022: pt=103 (L16 @16KHz/2, 512.0Kbps, 20ms vad plc disabled)



     如果在执行上一步中的pjsua命令时这样,./pjsip-apps/bin/pjsua-i686-pc-linux-gnu: error while loading shared libraries: libippsc.so.6.0: cannot open shared object file: No such file or directory

     还需要注意设置LD_LIBRARY_PATH



     动态链接IPP库编译过程完成。但是,如果其他程序想链接该版本的pjsip库时,也需要处理链接IPP的问题,非常不方便,接下来编译静态链接IPP版本的pjsip



5. 编译静态链接IPP库版本的pjsip



   主要是在链接阶段对build.mak工程文件的修改,其他地方设置与前一步一致。



   同样,解压pjproject-1.8.10.tar.bz2到一个新的目录,



   > cd pjproject-1.8.10-static-ipp



   configure一步仍旧使用上一步的命令,

   > ./configure --enable-ipp --with-ipp=$IPPROOT --with-ipp-samples=$IPPSAMPLES

 

   接下来要修改./build.mak, 这是configure生成的,在make时使用。对这个文件的修改在执行configure后修改消失。



   修改build.mak中的两个变量的值,APP_LDFLAGS, APP_LDLIBS,



   第一个变量APP_LDFLAGS,需要把-L$HOME/intel/ipp/6.0.1.071/ia32/sharedlib修改为,-L$HOME/intel/ipp/6.0.1.071/ia32/lib,告诉链接时搜索静态库所在目录。



   第二个变量APP_LDLIBS, 需要把IPP的动态库改为静态库名字,列表如下,注意,库的顺序一定按给出的顺序,否则编译的时候会有许多undefined reference问题。列表放在-lpj-$(TARGET_NAME) \行下面: (第一行和最后一行不需要修改,在这列出以便查找定位)

        -lpj-$(TARGET_NAME) \

        -lspeech -lcore \

        -lippdcemerged -lippdcmerged \

        -lippccemerged -lippccmerged \

        -lippacemerged -lippacmerged \

        -lippsremerged -lippsrmerged \

        -lippvcemerged -lippvcmerged \

        -lippiemerged -lippimerged \

        -lippjemerged -lippjmerged \

        -lippscemerged -lippscmerged \

        -lippsemerged -lippsmerged \

        -lippcore \

        -lm -lnsl -lrt -lpthread -lcrypto -lssl



     现在执行make编译出来的pjsua-程序即为静态链接IPP库的程序了。

    > make

    > ldd pjsip-apps/bin/pjsua-i686-pc-linux-gnu

        linux-gate.so.1 => (0xb7f58000)

        libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7f28000)

        libnsl.so.1 => /lib/i686/cmov/libnsl.so.1 (0xb7f0f000)

        librt.so.1 => /lib/i686/cmov/librt.so.1 (0xb7f05000)

        libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7eec000)

        libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7d99000)

        libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb7d52000)

        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7bf7000)

        /lib/ld-linux.so.2 (0xb7f59000)

        libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7bf2000)

        libz.so.1 => /usr/lib/libz.so.1 (0xb7bdd000)



     > ls -lh pjsip-apps/bin/pjsua-i686-pc-linux-gnu

      -rwxr-xr-x 1 test test 6.5M Dec 26 20:59 pjsip-apps/bin/pjsua-i686-pc-linux-gnu



     相比较动态链接IPP的程序,这个静态链接的版本明显变大了许多。



6. 在使用pjsip的其他应用程序中的编译链接问题

   对于动态链接的情况,在链接pjsip的同时,还需要维护工程文件,把IPP的include头文件路径加入到CFLAGS, 把IPP的sharedlib路径加入到LDFLAGS, 把IPP的动态库列举到工程文件中,-lippcore -lippcs等。



   对于静态链接的情况,其他应该程序不需要对IPP作任何设置,只把这个程序形成只依赖pjsip,无视pjsip对IPP的依赖即可,因为所有用到的IPP代码已经在pjsip的库中了。不过程序文件会变大不少。





参考:

http://trac.pjsip.org/repos/wiki/Intel_IPP_Codecs [^]

http://software.intel.com/en-us/forums/showthread.php?t=50294 [^]

http://centosyum.com/centos/p-2452.html [^]


原文: http://qtchina.tk/?q=node/536

Powered by zexport