jrtplib-3.7.1和jthread-1.2.1在交叉编译环境中的安装
环境:arm-linux交叉编译工具链4.4.3
ubuntu 11.04
1,首先下载jrtplib-3.7.1和jthread-1.2.1
例如,我建立了/root/vedio/JRTPLib文件夹,在里面建立
source:存放源码压缩包
src-arm:arm版本编译的源码
src-x86:x86版本的编译的源码
target-arm:arm版本的目标文件夹(生成的文件放在这里)
target-x86:x86版本的目标文件夹(在这里我直接将x86版本的默认装载了系统目录里,见上以部分,这里不赘述)
下载上述两个文件之后,分别将他们解压到src-arm ,和 src-x86(上面的x86版本已经测试过了,这里不做介绍,直接介绍交叉编译arm版本)
2,首先编译安装 jthread
进入jthread-1.2.1文件夹
编译方法:
./configure --prefix=/root/vedio/JRTPLib/target-arm --host=arm-linux CC=arm-linux-gcc CXX=arm-linux-g++
make
make install
在编译的时候出现了:configure: error: C compiler cannot create executables
原来是交叉编译换将的权限不对,重新安装交叉编译环境即可。
这时会看到/root/vedio/JRTPLib/target-arm多了include和lib文件。
3,编译安装jrtplib
/configure --host=arm-linux CXX=arm-linux-g++ CC=arm-linux-gcc --prefix=/root/vedio/JRTPLib/target-arm
make
在编译的时候又出现了和x86版本一样的错误
rtperrors.cpp:206: warning: deprecated conversion from string constant to 'char'
rtperrors.cpp:206: warning: deprecated conversion from string constant to 'char'
rtperrors.cpp: In function 'std::string RTPGetErrorString(int)':
rtperrors.cpp:225: error: 'snprintf' was not declared in this scope
make[1]: [rtperrors.lo] 错误 1
make[1]:正在离开目录 `/root/vedio/JRTPLib/src-arm/jrtplib-3.7.1/src'
make: [all-recursive] 错误 1
我们按照x86的思路,解决如下
进入src修改tperrors.h
增加:
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
再执行make make install即可。
4,尝试编译arm版本的程序
我们将/root/vedio/JRTPLib/target-arm/include中的jthread中的头文件全部拷贝到jrtplib3中,然后到src-arm目录下看到example文件夹。里面同样是测试文件,我们测试如下:
arm-linux-g++ example1.cpp -o example1 -L/root/vedio/JRTPLib/target-arm/lib -I/root/vedio/JRTPLib/target-arm/include/jrtplib3 -ljrtp -ljthread -lpthread
结果运行生成了example1可执行文件,使用file查看其文件类型发现他是arm平台的。则我们将/root/vedio/JRTPLib/target-arm/include中的头文件和/root/vedio/JRTPLib/target-arm/lib中的库文件拷贝到arm开发板上即可。
由这几次编译库我们可以发现,主要的步骤就是先编译依赖库,取得编译依赖库得到的头文件和库文件,在编译最终我们需要的库的时候,我们需要制定依赖库头文件和依赖库的位置,就像-L/root/vedio/JRTPLib/target-arm/lib -I/root/vedio/JRTPLib/target-arm/include/jrtplib3这种结构,所谓的移植不过如此而已。