您的位置:首页 > 编程语言 > PHP开发

HI3515上Jrtplib编译

2014-03-07 00:18 302 查看
操作环境:
Host OS: Windows 7
Guest OS: Ubuntu10
Develop Board: Hi3515
Cross-Complier: gcc-3.4.3-uClibc-0.9.28
 
关于 jrtp的一些说明:
说明 1: jrtp有两种数据接收方式:第一种是用
jthread库提供的线程自动在后台执行对数据的接收。第二种是用户自己调用RTPSession中的 Poll方法。如果采取第一种方法则要安装
jthread库,则安装 jthread-1.2.1.tar.gz,而且jthread-1.2.1必须先与jrtp-3.7.1的安装,不然会出现找不到
xxx.h的错误和非法的引用等的编译或连接错误。因为在 jrtp-3.7.1
的 configure中,会查找系统是否有编译了 jthread库,如果有,那么编译的
jrtp库会开启对 jthread的支持。因此如果先编译 jrtp在编译
jthread,编译出来的 jrtp是没有开启对 jthread的支持的。如果采用第二种方法,那么可以不用编译
jthread库,而直接编译 jrtp库。 
 
利用里面的测试例子时,先加上这几句:
#define WIN32
#pragma comment(lib, "jrtplib.lib")
#pragma comment(lib, "jthread.lib")
#pragma comment(lib, "ws2_32")
 
jrtplib.lib :warningLNK4204
缺少引用模块的调试信息;正在链接对象,如同没有调试信息一样
是因为之前生成的jrtplib库文件的时候是debug版本的,改成release版本的就可以了
 
jrtp-3.7.1.tar.gz 与 jthread-1.2.1.tar.gz的下载地址
http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib
 
 
一,编译为 PC所用:目的是在PC上生成库文件
PS:./configure –help
可以查看一些可以配置选项
jthread-1.2.1 的编译
[root@localhost pc-jrtp]#tar -zxvf jthread-1.2.1.tar.gz
[root@localhost pc-jrtp]#cd jthread- 1.2.1
[root@localhostjthread-1.2.1]# ./configure --prefix=/opt/hi3515/pc-jrtp
[root@localhostjthread-1.2.1]# make
[root@localhostjthread-1.2.1]# make install
说明 : --prefix=指定编译后的 jthread库安装到什么目录。
 
执行 make install时会出现如下信息:
-----------------------------------------------------------------
Libraries have beeninstalled in:
   /opt/hi3515/pc-jrtp/lib
 
If you ever happen towant to link against installed libraries
in a given directory,LIBDIR, you must either use libtool, and
specify the full pathnameof the library, or use the `-LLIBDIR'
flag during linking anddo at least one of the following:
   - add LIBDIRto the `LD_LIBRARY_PATH' environment variable
    during execution
    - addLIBDIR to the `LD_RUN_PATH' environment variable
    during linking
   - use the`-Wl,--rpath -Wl,LIBDIR' linker flag
   - have yoursystem administrator add LIBDIR to `/etc/ld.so.conf'
 
See any operating systemdocumentation about shared libraries for
more information, such asthe ld(1) and ld.so(8) manual pages.
-----------------------------------------------------------------
这段英文告诉我们编译后的 jthread库安装到什么目录下,而且如果使用这个库编译自己的文件应该怎么做。可以参考静态函数库与动态函数库。
 
安装成功后在自己指定目录下有 : include与 lib两个文件夹
include 中又有一个 jthread的文件夹,里面包含了
jthread库的头文件
lib 中包含了编译成功的 jthread库:包括动态库libjthread-1.2.1.so与静态库
libjthread.a
 
(2) jrtplib-3.7.1 的编译
[root@localhost pc-jrtp]#tar -zxvf jrtplib-3.7.1.tar.gz
[root@localhost pc-jrtp]#cd jrtplib- 3.7.1
[root@localhost pc-jrtp]#./configure --prefix=/opt/hi3515/pc-jrtp/ --with-jthread-includes=/opt/hi3515/pc-jrtp/include/jthreadLDFLAGS=-L/opt/hi3515/pc-jrtp/lib
说明:
--prefix= --prefix :指定编译后的 jrtplib库安装到什么目录。
--with-jthread-includes
:指定之前安装的 jthread库的头文件安装在什么目录下。如果不需要 jthread的支持,这个选项可以不用。
LDFLAGS :为编译时需要连接的动态库的路径。如果不需要 jthread库的支持,这个选项不要。
 
configure 过程中出现的提示信息:
checking for JThreadinclude files... in "/opt/hi3515/pc-jrtp/include/jthread"
checking JThreadversion... >= 1.1.0
checking if we can linkagainst jthread and pthread... yes
说明 jthread路径正确,配置文件开启了对 jthread的支持。
 
接着进行 make与 makeinstall
[root@localhost jrtplib-3.7.1]#make
[root@localhostjrtplib-3.7.1]# make install
在不修改源文件情况下 , make的过程中直接编译可能出现的错误:
在 Fedora 9中 make提示的错误:
rtppacket.cpp:311: error:'memcpy' was not declared in this scope
或者:
在 Fedora 13中 make提示的错误:
rtperrors.cpp: Infunction 'std::string RTPGetErrorString(int)':
rtperrors.cpp:225: error:'snprintf' was not declared in this scope
在 Ubuntu10中 make提示的错误:
rtperrors.cpp:225: error:'snprintf' was not declared in this scope
为了 make成功,需要修改 jrtplib-3.7.1源文件rtpdefines.h
添加如下语句 : 

#include <stdio.h> 

#include <stdarg.h> 

#include <string.h>
操作如下:
[root@localhostjrtplib-3.7.1]# cd src/
[root@localhost src]# vimrtpdefines.h
// rtpdefines.h
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#if (defined(WIN32) ||defined(_WIN32_WCE))
#if(!defined(_WIN32_WCE)) && (defined(_MSC_VER) && _MSC_VER >=1400 )
#define RTP_SNPRINTF _snprintf_s
#else
#define RTP_SNPRINTF _snprintf
#endif
#else
#defineRTP_SNPRINTF snprintf
#endif // WIN32 ||_WIN32_WCE
重新 make后可以成功。
 
make isntall 后有如下信息
-----------------------------------------------------------------
Libraries have beeninstalled in:
   /opt/hi3515/pc-jrtp/lib
 
If you ever happen towant to link against installed libraries
in a given directory,LIBDIR, you must either use libtool, and
specify the full pathnameof the library, or use the `-LLIBDIR'
flag during linking anddo at least one of the following:
   - add LIBDIRto the `LD_LIBRARY_PATH' environment variable
    during execution
   - add LIBDIRto the `LD_RUN_PATH' environment variable
    during linking
   - use the`-Wl,--rpath -Wl,LIBDIR' linker flag
   - have yoursystem administrator add LIBDIR to `/etc/ld.so.conf'
 
See any operating systemdocumentation about shared libraries for
more information, such asthe ld(1) and ld.so(8) manual pages.
-----------------------------------------------------------------
这段英文告诉我们编译后的 jrtp库安装到什么目录下,而且如果使用这个库编译自己的文件应该怎么做。
 
安装成功后在自己指定目录下有 :include与 lib两个文件夹
include 中又有一个 jrtplib的文件夹,里面包含了
jrtplib库的头文件
lib 中包含了编译成功的 jrtp库:包括动态库
libjrtp-3.7.1.so与静态库libjrtp.a。
 
 
二,编译为 Hi3515(ARM)所用 :这个是为了编译出开发板可以使用的库文件。
步骤与编译为 PC所用一样,但是 configure的设置过有所不同,现在说明:
(1)  对于 jthread
首先要进到jthread1.2.1目录,然后输入下面命令
./configure --prefix=/opt/mini2440/arm-jrtp CC=arm-linux-gcc CXX=arm-linux-g++ –-host=arm-linux
注意:上面命令中的host选项在Ubuntu10中要使用--host.后面的arm-linux需要在当前目录下运行./config.guess之后会显示出结果,我这里显示的是i686-pc-linux-gnu,而对于CC选项和CXX选项,要填写交叉编译环境中编译命令所在的路径,我这里填写的是CC=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/arm-hisi-linux-gccCXX=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/arm-hisi-linux-g++
所以完整的命令是:
./configure--prefix=/opt/hi3515/arm-jrtpCC=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/arm-hisi-linux-gccCXX=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/arm-hisi-linux-g++--host=i686-pc-linux-gnu
然后再输入make和 make install进行编译
(2)  对于 jrtlib
进入jrtlib3.7.1目录,在输入下
./configure -prefix=/opt/mini2440/arm-jrtp–host=arm-linux –with-jthread-includes=/opt/mini2440/arm-jrtp/includesCC=arm-linux-gcc CXX=arm-linux LDFLAGS=-L/opt/mini2440/arm-jrtp/lib
./configure-prefix=/opt/hi3515/arm-jrtp-with-jthread-includes=/opt/hi3515/arm-jrtp/includes CC=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/arm-hisi-linux-gccCXX=/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/arm-hisi-linux-g++LDFLAGS=-L/opt/hi3515/arm-jrtp/lib
--host=i686-pc-linux-gnu
然后会看到如下提示信息:
ASSUMING TARGET IS BIGENDIAN:
    Thescript detected a cross-compiler on your system. This can mean that
  there really is across-compiler installed, or that for some other reason,
  a simple programcould not be run. You should check the config.log file
  to verify this.
  Since we are assuminga cross-compiler, we won't be able to actually test
  any program. Moreimportant, we cannot test if the system is big or little
  endian.
  For now, bigendian is assumed. If this assumption should be wrong, you will
  have to commentthe appropriate line in 'rtpconfig_unix.h'
说明: configure把目标平台默认为是大端模式。如果需要改变则要修改rtpconfig_
unix.h。
 
我们那么应该测试开发板是大端模式还是小端模式:
至于什么是大端模式,什么小端模式,以及为什么要测试请看我博客上的大端模式与小端模式。
 
测试程序:
#include
int main(void)
{
int num= 0x1234;
char *p= #
if (*p== 0x12){
printf("BigEndian\n");
}
else{
printf("LittleEndian\n");
}
return0;
}
保存后用交叉编译器编译生成可执行文件后,放到目标平台上执行。从而判断出目标平台是什么模式。
经过测试,为小端模式,即低地址存低字节,高地址存高字节。*p为0x34,*(p+1)为0x12
通过测试下,得知 HI3515默认为小端模式,因此需要修改 rtpconfig_
unix.h
文件在 :
jrtplib-3.7.1/src目录下
修改操作如下:
33 #ifndefRTPCONFIG_UNIX_H
  34
  35 #defineRTPCONFIG_UNIX_H
  36
  37 // Don't have
  38
  39 // Don't have
  40
  41 //#defineRTP_BIG_ENDIAN // comment this if the target is a little endian system
  42
  43 #defineRTP_SOCKLENTYPE_UINT
则是把第 41行注释了。注释后则以小段模式来编译。
然后就可以 make与 makeinstall了。
 如果提示错误:
Relocationsin generic ELF (EM: 3)
/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/../lib/gcc/arm-hisi-linux/3.4.3/../../../../arm-hisi-linux/bin/ld:.libs/rtplibraryversion.o: Relocations in generic ELF (EM: 3)
/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/../lib/gcc/arm-hisi-linux/3.4.3/../../../../arm-hisi-linux/bin/ld:.libs/rtplibraryversion.o: Relocations in generic ELF (EM: 3)
.libs/rtplibraryversion.o: could notread symbols: File in wrong format
collect2: ld returned 1 exit status
make[1]: *** [libjrtp.la]
错误 1
make[1]:正在离开目录`/root/Hi3515/jrtplib-3.7.1/src'
make: *** [all-recursive]
错误 1
需要执行如下命令就可以解决:
#make clean -w
 
三,最后一步就是测试了:
(1) 首先把编译为 PC所用的库文件:
libjrtp-3.7.1.so与 libjthread.so复制到 Fedora9的
/lib。
(2) 把交叉编译后生成的库文件 :libjrtp-3.7.1.so与
libjthread.so复制到开发板上的 /lib。
(3) 执行 jrtp-3.7.1/example下的
exampl4。编译在pc端运行的程序时,不要加本文开头的说明#paragrm…..那几句话,不然会报错
[root@localhostexamples]# ./example4
Enter local portbase:
9090
  
Number of seconds youwish to wait:
500
 
(4) 把/opt/mini2440/arm-jrtp/jrtp-3.7.1/example目录复制到开发板上并执行
exampl1。
[root@FriendlyARMdownload]# ./example1
Enter local portbase:
9090
 
Enter the destination IPaddress
192.168.0.2
Enter the destinationport
9090
 
Number of packets you wishto be sent:
50
 
(5) 如果在 PC上出现
Got packet则表示可以收到开发板发过来的数据包
Got packet 32390 fromSSRC 609572025
Got packet 32391 fromSSRC 609572025
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: