JRTP库与JTHREAD库的编译与移植

2023-11-22 19:48
文章标签 编译 移植 jthread jrtp

本文主要是介绍JRTP库与JTHREAD库的编译与移植,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

操作环境:

Host OS: Windows 7

VMware Workstation: 6.5.1

Guest OS: Fedora 9

Develop Board: MINI2440

Cross-Complier: ARM-Linux-GCC 4.3.2

 

关于 jrtp 的一些说明:

说明 1 : jrtp 有两种数据接收方式:第一种是用 jthread 库提供的线程自动在后台执行对数据的接收。第二种是用户自己调用 RTPSession 中的 Poll 方法。如果采取第一种方法则要安装 jthread 库,则安装jthread-1.2.1.tar.gz ,而且 jthread-1.2.1 必须先与 jrtp-3.7.1 的安装。因为在 jrtp-3.7.1 的configure 中,会查找系统是否有编译了 jthread 库,如果有,那么编译的 jrtp 库会开启对 jthread 的支持。因此如果先编译 jrtp 在编译 jthread ,编译出来的 jrtp 是没有开启对 jthread 的支持的。如果采用第二种方法,那么可以不用编译 jthread 库,而直接编译 jrtp 库。

 

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 所用:

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@localhost jthread-1.2.1]# ./configure --prefix=/opt/mini2440/pc-jrtp

[root@localhost jthread-1.2.1]# make

[root@localhost jthread-1.2.1]# make install

说明 : --prefix= 指定编译后的 jthread 库安装到什么目录 。

 

执行 make install 时会出现如下信息:

-----------------------------------------------------------------

Libraries have been installed in:

   /opt/mini2440/pc-jrtp/lib

 

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

     during execution

    - add LIBDIR to the `LD_RUN_PATH' environment variable

     during linking

   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

 

See any operating system documentation about shared libraries for

more information, such as the 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/mini2440/pc-jrtp/ --with-jthread-includes=/opt/mini2440/pc-jrtp/include/jthread LDFLAGS=-L/opt/mini2440/pc-jrtp/lib

说明:

--prefix= --prefix :指定编译后的 jrtplib 库安装到什么目录。

--with-jthread-includes :指定之前安装的 jthread 库的头文件安装在什么目录下。如果不需要 jthread的支持,这个选项可以不用。

LDFLAGS :为编译时需要连接的动态库的路径。如果不需要 jthread 库的支持,这个选项不要。

 

configure 过程中出现的提示信息:

checking for JThread include files... in "/opt/mini2440/pc-jrtp/include/jthread"

checking JThread version... >= 1.1.0

checking if we can link against jthread and pthread... yes

说明 jthread 路径正确,配置文件开启了对 jthread 的支持。

 

接着进行 make 与 make install

[root@localhost jrtplib-3.7.1]# make

[root@localhost jrtplib-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: In function 'std::string RTPGetErrorString(int)':

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@localhost jrtplib-3.7.1]# cd src/

[root@localhost src]# vim rtpdefines.h

// rtpdefines.h

75 #include <stdio.h>

  76 #include <stdarg.h>

  77 #include <string.h>

  78 #if (defined(WIN32) || defined(_WIN32_WCE))

  79         #if (!defined(_WIN32_WCE)) && (defined(_MSC_VER) && _MSC_VER >= 1400 )

  80                 #define RTP_SNPRINTF _snprintf_s

  81         #else

  82                 #define RTP_SNPRINTF _snprintf

  83         #endif

  84 #else

  85         #define RTP_SNPRINTF snprintf

  86 #endif // WIN32 || _WIN32_WCE

重新 make 后可以成功。

 

make isntall 后有如下信息

-----------------------------------------------------------------

Libraries have been installed in:

   /opt/mini2440/pc-jrtp/lib

 

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

     during execution

   - add LIBDIR to the `LD_RUN_PATH' environment variable

     during linking

   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

 

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

-----------------------------------------------------------------

这段英文告诉我们编译后的 jrtp 库安装到什么目录下,而且如果使用这个库编译自己的文件应该怎么做。

 

安装成功后在自己指定目录下有 :include 与 lib 两个文件夹

include 中又有一个 jrtplib 的文件夹,里面包含了 jrtplib 库的头文件

lib 中包含了编译成功的 jrtp 库:包括 动态库 libjrtp-3.7.1.so 与 静态库 libjrtp.a 

 

 

二,编译为 MINI2440(ARM) 所用 :

步骤与编译为 PC 所用一样,但是 configure 的设置过有所不同,现在说明:

(1) 对于 jthread

./configure  --prefix=/opt/mini2440/arm-jrtp –host=arm-linux CC=arm-linux-gcc CXX=arm-linux-g++

(2) 对于 jrtlib

./configure –prefix=/opt/mini2440/arm-jrtp –host=arm-linux –with-jthread-includes=/opt/mini2440/arm-jrtp/includes CC=arm-linux-gcc CXX=arm-linux LDFLAGS=-L/opt/mini2440/arm-jrtp/lib

然后会看到如下提示信息:

ASSUMING TARGET IS BIG ENDIAN:

    The script detected a cross-compiler on your system. This can mean that

  there really is a cross-compiler installed, or that for some other reason,

  a simple program could not be run. You should check the config.log file

  to verify this.

  Since we are assuming a cross-compiler, we won't be able to actually test

  any program. More important, we cannot test if the system is big or little

  endian.

  For now, big endian is assumed. If this assumption should be wrong, you will

  have to comment the appropriate line in 'rtpconfig_unix.h'

说明 : configure 把目标平台默认为是大端模式。如果需要改变则要修改 rtpconfig_ unix.h 。

 

我们那么应该测试开发板是大端模式还是小端模式:

至于什么是大端模式,什么小端模式,以及为什么要测试请看我博客上的大端模式与小端模式。

 

测试程序:

1 #include

  2 int main(void)

  3 {

  4         int num = 0x1234;

  5         char *p = &num;

  6         if (*p == 0x12){

  7                 printf("Big Endian/n");

  8         }

  9         else{

  10                 printf("Little Endian/n");

  11         }

  12         return 0;

  13  }

保存后用交叉编译器编译生成可执行文件后,放到目标平台上执行。从而判断出目标平台是什么模式。

通过测试下,得知 MINI2440 默认为小端模式,因此需要修改 rtpconfig_ unix.h

文件在 :

/opt/mini2440/arm-jrtp/jrtplib-3.7.1/src

修改操作如下:

33 #ifndef RTPCONFIG_UNIX_H

  34

  35 #define RTPCONFIG_UNIX_H

  36

  37 // Don't have

  38

  39 // Don't have

  40

  41 //#define RTP_BIG_ENDIAN // comment this if the target is a little endian system

  42

  43 #define RTP_SOCKLENTYPE_UINT

则是把第 41 行注释了 。注释后则以小段模式来编译。

然后就可以 make 与 make install 了。

 

三,最后一步就是测试了:

(1) 首先把编译为 PC 所用的库文件: libjrtp-3.7.1.so 与 libjthread.so 复制到 Fedora9 的 /lib 。

(2) 把交叉编译后生成的库文件 :libjrtp-3.7.1.so 与 libjthread.so 复制到开发板上的 /lib 。

(3) 执行 /opt/mini2440/pc-jrtp/jrtp-3.7.1/example 下的 exampl4 。

[root@localhost examples]# ./example4

Enter local portbase:

9090

 

 

Number of seconds you wish to wait:

500

 

(4) 把 /opt/mini2440/arm-jrtp/jrtp-3.7.1/example 目录复制到开发板上并执行 exampl1 。

[root@FriendlyARM download]# ./example1

Enter local portbase:

9090

 

Enter the destination IP address

192.168.0.2

Enter the destination port

9090

 

Number of packets you wish to be sent:

50

 

(5) 如果在 PC 上出现 Got packet 则表示可以收到开发板发过来的数据包

Got packet 32390 from SSRC 609572025

Got packet 32391 from SSRC 609572025

…….


这篇关于JRTP库与JTHREAD库的编译与移植的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/412483

相关文章

IDEA编译报错“java: 常量字符串过长”的原因及解决方法

《IDEA编译报错“java:常量字符串过长”的原因及解决方法》今天在开发过程中,由于尝试将一个文件的Base64字符串设置为常量,结果导致IDEA编译的时候出现了如下报错java:常量字符串过长,... 目录一、问题描述二、问题原因2.1 理论角度2.2 源码角度三、解决方案解决方案①:StringBui

解决IDEA使用springBoot创建项目,lombok标注实体类后编译无报错,但是运行时报错问题

《解决IDEA使用springBoot创建项目,lombok标注实体类后编译无报错,但是运行时报错问题》文章详细描述了在使用lombok的@Data注解标注实体类时遇到编译无误但运行时报错的问题,分析... 目录问题分析问题解决方案步骤一步骤二步骤三总结问题使用lombok注解@Data标注实体类,编译时

maven 编译构建可以执行的jar包

💝💝💝欢迎莅临我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」👈,「stormsha的知识库」👈持续学习,不断总结,共同进步,为了踏实,做好当下事儿~ 专栏导航 Python系列: Python面试题合集,剑指大厂Git系列: Git操作技巧GO

FreeRTOS-基本介绍和移植STM32

FreeRTOS-基本介绍和STM32移植 一、裸机开发和操作系统开发介绍二、任务调度和任务状态介绍2.1 任务调度2.1.1 抢占式调度2.1.2 时间片调度 2.2 任务状态 三、FreeRTOS源码和移植STM323.1 FreeRTOS源码3.2 FreeRTOS移植STM323.2.1 代码移植3.2.2 时钟中断配置 一、裸机开发和操作系统开发介绍 裸机:前后台系

Windows环境利用VS2022编译 libvpx 源码教程

libvpx libvpx 是一个开源的视频编码库,由 WebM 项目开发和维护,专门用于 VP8 和 VP9 视频编码格式的编解码处理。它支持高质量的视频压缩,广泛应用于视频会议、在线教育、视频直播服务等多种场景中。libvpx 的特点包括跨平台兼容性、硬件加速支持以及灵活的接口设计,使其可以轻松集成到各种应用程序中。 libvpx 的安装和配置过程相对简单,用户可以从官方网站下载源代码

Golang test编译使用

创建文件my_test.go package testsimport "testing"func TestMy(t *testing.T) {t.Log("TestMy")} 通常用法: $ go test -v -run TestMy my_test.go=== RUN TestMyTestMy: my_test.go:6: TestMy--- PASS: TestMy (0.

C++/《C/C++程序编译流程》

程序的基本流程如图:   1.预处理        预处理相当于根据预处理指令组装新的C/C++程序。经过预处理,会产生一个没有宏定义,没有条件编译指令,没有特殊符号的输出文件,这个文件的含义同原本的文件无异,只是内容上有所不同。 读取C/C++源程序,对其中的伪指令(以#开头的指令)进行处理将所有的“#define”删除,并且展开所有的宏定义处理所有的条件编译指令,如:“#if”、“

编译linux内核出现 arm-eabi-gcc: error: : No such file or directory

external/e2fsprogs/lib/ext2fs/tdb.c:673:29: warning: comparison between : In function 'max2165_set_params': -。。。。。。。。。。。。。。。。。。 。。。。。。。。。。。。。 。。。。。。。。 host asm: libdvm <= dalvik/vm/mterp/out/Inte

QT 编译报错:C3861: ‘tr‘ identifier not found

问题: QT 编译报错:C3861: ‘tr’ identifier not found 原因 使用tr的地方所在的类没有继承自 QObject 类 或者在不在某一类中, 解决方案 就直接用类名引用 :QObject::tr( )

hector_quadrotor编译总结 | ubuntu 16.04 ros-kinetic版本

hector_quadrotor编译总结 | ubuntu 16.04 ros-kinetic版本 基于Ubuntu 16.04 LTS系统所用ROS版本为 Kinetic hector_quadrotor ROS包主要用于四旋翼无人机的建模、控制和仿真。 1.安装依赖库 所需系统及依赖库 Ubuntu 16.04|ros-kinetic|Gazebo|gazebo_ros_pkgs|ge