jrtplib 编译安装配置

【来源】http://blog.csdn.net/li_wen01/article/details/69526179

    RTP 是目前解决流媒体实时传输问题的最好办法,而JRTPLIB 是一个用C++语言实现的RTP库,包括UDP通讯,它的主页地址是:Jori's page

    jrtplib 源码的获取,可以在它的主页上直接下载,也可以使用Git 直接克隆一份。因为它的主页是国外网站,下载速度非常慢,我这里提供一份已经下载好的最新的jrtplib源码:jrtplib-3.11.1.tar.gz

    我这里介绍JRTPLIB在ubuntu系统中的编译安装以及配置

    (1)下载源码:

        git clone https://github.com/j0r1/JRTPLIB.git


    (2)安装cmake

        sudo apt install cmake


    (3)生成Makefile 文件

        sudo cmake CMakeLists.txt 


    (4)编译

        make


    (5)安装

        sudo make  install

    可以看到已经安装到下面的路径去了:

  1. .....................  
  2. -- Installing: /usr/local/include/jrtplib3/rtpudpv4transmitter.h  
  3. -- Installing: /usr/local/include/jrtplib3/rtpudpv6transmitter.h  
  4. -- Installing: /usr/local/include/jrtplib3/rtpbyteaddress.h  
  5. -- Installing: /usr/local/include/jrtplib3/rtpexternaltransmitter.h  
  6. -- Installing: /usr/local/include/jrtplib3/rtpsecuresession.h  
  7. -- Installing: /usr/local/include/jrtplib3/rtpsocketutil.h  
  8. -- Installing: /usr/local/include/jrtplib3/rtpabortdescriptors.h  
  9. -- Installing: /usr/local/include/jrtplib3/rtpselect.h  
  10. -- Installing: /usr/local/include/jrtplib3/rtptcpaddress.h  
  11. -- Installing: /usr/local/include/jrtplib3/rtptcptransmitter.h  
  12. -- Installing: /usr/local/include/jrtplib3/rtpfaketransmitter.h  
  13. -- Installing: /usr/local/lib/libjrtp.a  
  14. -- Installing: /usr/local/lib/libjrtp.so.3.11.1  
  15. -- Installing: /usr/local/lib/libjrtp.so  
.....................
-- Installing: /usr/local/include/jrtplib3/rtpudpv4transmitter.h
-- Installing: /usr/local/include/jrtplib3/rtpudpv6transmitter.h
-- Installing: /usr/local/include/jrtplib3/rtpbyteaddress.h
-- Installing: /usr/local/include/jrtplib3/rtpexternaltransmitter.h
-- Installing: /usr/local/include/jrtplib3/rtpsecuresession.h
-- Installing: /usr/local/include/jrtplib3/rtpsocketutil.h
-- Installing: /usr/local/include/jrtplib3/rtpabortdescriptors.h
-- Installing: /usr/local/include/jrtplib3/rtpselect.h
-- Installing: /usr/local/include/jrtplib3/rtptcpaddress.h
-- Installing: /usr/local/include/jrtplib3/rtptcptransmitter.h
-- Installing: /usr/local/include/jrtplib3/rtpfaketransmitter.h
-- Installing: /usr/local/lib/libjrtp.a
-- Installing: /usr/local/lib/libjrtp.so.3.11.1
-- Installing: /usr/local/lib/libjrtp.so


    (6)修改头文件引用

    这个时候编译jrtplib 自带的示例程序,会出现下面的错误:

  1. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ g++ example1.cpp -o test -ljrtp  
  2. example1.cpp:6:24: fatal error: rtpsession.h: No such file or directory  
  3. compilation terminated.  
  4. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$   
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ g++ example1.cpp -o test -ljrtp
example1.cpp:6:24: fatal error: rtpsession.h: No such file or directory
compilation terminated.
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ 
    这个是头文件路径不对引起的。可以直接修改头文件的引用,如下:

  1. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ vim example1.cpp   
  2.   1 /* 
  3.   2    Here's a small IPv4 example: it asks for a portbase and a destination and  
  4.   3    starts sending packets to that destination. 
  5.   4 */  
  6.   5   
  7.   6 #include <jrtplib3/rtpsession.h>  
  8.   7 #include <jrtplib3/rtpudpv4transmitter.h>  
  9.   8 #include <jrtplib3/rtpipv4address.h>  
  10.   9 #include <jrtplib3/rtpsessionparams.h>  
  11.  10 #include <jrtplib3/rtperrors.h>  
  12.  11 #include <jrtplib3/rtplibraryversion.h>  
  13.  12 #include <stdlib.h>  
  14.  13 #include <stdio.h>  
  15.  14 #include <iostream>  
  16.  15 #include <string>  
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ vim example1.cpp 
  1 /*
  2    Here's a small IPv4 example: it asks for a portbase and a destination and 
  3    starts sending packets to that destination.
  4 */
  5 
  6 #include <jrtplib3/rtpsession.h>
  7 #include <jrtplib3/rtpudpv4transmitter.h>
  8 #include <jrtplib3/rtpipv4address.h>
  9 #include <jrtplib3/rtpsessionparams.h>
 10 #include <jrtplib3/rtperrors.h>
 11 #include <jrtplib3/rtplibraryversion.h>
 12 #include <stdlib.h>
 13 #include <stdio.h>
 14 #include <iostream>
 15 #include <string>
    修改后可编译通过并生成可执行文件

  1. "example1.cpp" 147L, 3436C written                                                                                                               
  2. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ g++ example1.cpp -o test -ljrtp  
  3. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ ls  
  4. CMakeFiles           CMakeLists.txt  example2.cpp  example4.cpp  example6.cpp  example8.cpp  test  
  5. cmake_install.cmake  example1.cpp    example3.cpp  example5.cpp  example7.cpp  Makefile  
  6. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$   
"example1.cpp" 147L, 3436C written                                                                                                             
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ g++ example1.cpp -o test -ljrtp
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ ls
CMakeFiles           CMakeLists.txt  example2.cpp  example4.cpp  example6.cpp  example8.cpp  test
cmake_install.cmake  example1.cpp    example3.cpp  example5.cpp  example7.cpp  Makefile
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ 

    (7)配置共享链接库

        直接运行上面生成的test 文件会出现下面的问题:

  1. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ ./test   
  2. ./test: error while loading shared libraries: libjrtp.so.3.11.1: cannot open shared object file: No such file or directory  
  3. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$   
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ ./test 
./test: error while loading shared libraries: libjrtp.so.3.11.1: cannot open shared object file: No such file or directory
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ 
        这个是共享连接库连接不到的问题,执行下面命令:

  1. sudo ln -s /usr/local/lib/libjrtp.so.3.11.1 /usr/lib/  
sudo ln -s /usr/local/lib/libjrtp.so.3.11.1 /usr/lib/

      之后运行程序,可正常运行。

  1. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ ./test   
  2. Using version 3.11.1  
  3. Enter local portbase:  
  4. 6666  
  5.   
  6. Enter the destination IP address  
  7. 192.168.0.6  
  8. Enter the destination port  
  9. 6666  
  10.   
  11. Number of packets you wish to be sent:  
  12. 10  
  13.   
  14. Sending packet 1/10  
  15.   
  16. Sending packet 2/10  
  17.   
  18. Sending packet 3/10  
  19.   
  20. Sending packet 4/10  
  21.   
  22. Sending packet 5/10  
  23.   
  24. Sending packet 6/10  
  25.   
  26. Sending packet 7/10  
  27.   
  28. Sending packet 8/10  
  29.   
  30. Sending packet 9/10  
  31.   
  32. Sending packet 10/10  
  33. licaibiao@lcb:~/test/RTP/JRTPLIB/examples$   
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ ./test 
Using version 3.11.1
Enter local portbase:
6666

Enter the destination IP address
192.168.0.6
Enter the destination port
6666

Number of packets you wish to be sent:
10

Sending packet 1/10

Sending packet 2/10

Sending packet 3/10

Sending packet 4/10

Sending packet 5/10

Sending packet 6/10

Sending packet 7/10

Sending packet 8/10

Sending packet 9/10

Sending packet 10/10
licaibiao@lcb:~/test/RTP/JRTPLIB/examples$ 

0
0
 
 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值