Jrtplib rtp(3.7.1)开源库和jthread1.2.1安装(非交叉编译版以及交叉编译版)
Linux (非交叉编译版)
1.要安装jrtplib前要先将开源函数库jthread1.2.1安装
Jthread(非交叉编译版)的安装:
进入jthread-1.2.1文件夹
运行:j./configure (可加上–prefix=(路径)配置安装路径//例子:./configure -prefix=/usr/local/jthread/,也可选择默认路径/usr/local/include/jthread/和/usr/local/lib/,则不需-prefix)
k make
l make install
2.接着则可以安装jrtplib:
进入Jrtplib-3.7.1文件夹
运行:j./configure (可加上–prefix=(路径)配置安装路径//例子:./configure -prefix=/usr/local/jrtp/,也可选择默认路径/usr/local/include/jrtplib3/和/usr/local/lib/,则不需-prefix)
k make
l make install
Linux (交叉编译版)
1.要安装jrtplib前要先将开源函数库jthread1.2.1安装
Jthread(非交叉编译版)的安装:
进入jthread-1.2.1文件夹
运行:j ./configure -host=arm-linux (可加上–prefix=(路径)配置安装路径//例子:./configure -prefix=/usr/local/jthread/,也可选择默认路径/usr/local/include/jthread/和/usr/local/lib/,则不需-prefix,-host=arm-linux 是选择交叉编译工具,configure过程中会自动搜索交叉编译工具,交叉编译工具的安装则按照arm开发版配送的说明安装)
k make
l make install
2.接着则可以安装jrtplib:
进入Jrtplib-3.7.1/src/文件夹
j:修改相关文件:
rtpsession.cpp中的createCNAME函数有问题
if (!gotlogin)
{
// char *logname = getenv("LOGNAME");
if (logname == 0)
return ERR_RTP_SESSION_CANTGETLOGINNAME;
strncpy((char *)buffer,logname,*bufferlength);
}
logname要求获得登陆名,而板子一般没有登陆名,将其强制改为root即可
if (!gotlogin)
{
// char *logname = getenv("LOGNAME");
char *logname = "root";
if (logname == 0)
return ERR_RTP_SESSION_CANTGETLOGINNAME;
strncpy((char *)buffer,logname,*bufferlength);
}
rtperrors.h :
添加 #include
#include
原因在于:在编译过程中会找不到snpringtf函数的声明
rtcpcompoundpacketbuilder.cpp和 rtppacket.cpp :
添加 #include
原因在于:在编译过程中会找不到memcp函数的声明
k进入Jrtplib-3.7.1/文件夹
运行./configure -host=arm-linux (可加上–prefix=(路径)配置安装路径//例子:./configure -prefix=/usr/local/jrtp/,也可选择默认路径/usr/local/include/jrtplib3/和/usr/local/lib,则不需-prefix,-host=arm-linux 是选择交叉编译工具,configure过程中会自动搜索交叉编译工具,交叉编译工具的安装则按照arm开发版配送的说明安装)
注意:运行完这步之后要进入Jrtplib-3.7.1/src/文件夹修改相关文件
具体修改方案如下:
rtpconfig_unix.h:
注释掉 //#define RTP_BIG_ENDIAN // comment this if the target is a little endian system
原因在于:x86的pc机是用小端字节序(little endian),而嵌入式平台一般是大端字节序(big endian),可能是由于字节序的不同,导致了明明存在数据包,却认不出来的问题,造成pc与arm双方接收不到数据,如果是arm与arm之间则不需要注释掉
l make
mmake install
可到/usr/local/lib 中file libjrtplib-3.7.1.so查看libjrtplib-3.7.1.so的cpu架构,看是否交叉编译成功
非交叉编译版:
为了便于以后使用,可将libjrtplib-3.7.1.so和libjthread-1.2.1.so复制到/usr/bin文件夹下,将/usr/local/include/jrtplib3和/usr/local/include/jthread下所有的头文件复制到/usr/include下,或是自己将头文件和libjrtplib-3.7.1.so和libjthread-1.2.1.so的地址添加到编译器的头文件路径和库路径,否则每次都要输入大段编译语句)
编译文件时:非交叉编译版:编译jrtplib-3.7.1/examples下的example1.
g++ -o example1 example1.cpp -ljthread -ljrtp 就会生成example1(-ljthread 是链接libjthread-1.2.1.so库,-ljrtp是链接libjrtplib-3.7.1.so库,如没有将libjrtplib-3.7.1.so和libjthread-1.2.1.so复制到/usr/bin文件夹下,将/usr/local/include/jrtplib3和/usr/local/include/jthread下所有的头文件复制到/usr/include下,或是没有将头文件和libjrtplib-3.7.1.so和libjthread-1.2.1.so的地址添加到编译器的头文件路径和库路径,则编译语句如下:g++ -o example1 example1.cpp -I /usr/local/include/jrtplib3/ -I /usr/local/include/jthread -L /usr/local/lib/ -ljrtp -L /usr/local/lib/ -ljthread –lpthread 动态添加头文件路径和库文件路径,通过ldd example1,即可查询程序example1的同台链接库,也可使用这样的编译语句:g++ -static -o example5 example5.cpp -I /usr/local/include/jrtplib3/ -I /usr/local/include/jthread -L /usr/local/lib/ -ljrtp -L /usr/local/lib/ -ljthread -lpthread 将库包含到程序中,就不需动态链接库,使用ldd example1,显示不出任何库,当这样的程序文件很大,但可以在其他没有安装库的linux上运行)
交叉编译版:
为了便于以后使用,自己将头文件和libjrtplib-3.7.1.so和libjthread-1.2.1.so的地址添加到交叉编译器的头文件路径和库路径 ,编译jrtplib-3.7.1/examples下的example1.
arm-linux-g++ -static -o example1 example1.cpp -ljthread -ljrtp –lpthread 就会生成example1,使用-static是为了能在不带相关库的arm上运行,加上–lpthread是为libjthread-1.2.1.so提供pthread库,如果没有将头文件和libjrtplib-3.7.1.so和libjthread-1.2.1.so的地址添加到交叉编译器的头文件路径和库路径,编译语句如下arm-linux-g++ -static -o example1 example1.cpp -I /usr/local/include/jrtplib3/ -I /usr/local/include/jthread -L /usr/local/lib/ -ljrtp -L /usr/local/lib/ -ljthread –lpthread 可用file example1查看程序的cpu架构。
卸载:无论是交叉编译版还是非交叉编译版都可以分别在jthread-1.2.1文件夹和Jrtplib-3.7.1文件夹中运行make uninstall,即可卸载这两个库。