1.官网下载
[root@demo rtmpdump]# git clone git://git.ffmpeg.org/rtmpdump
2.执行交叉编译
[root@demo rtmpdump]# make SYS=posix CROSS_COMPILE=arm-hisiv300-linux- INC=-I/usr/include
make[1]: Entering directory `/home/Hi3516A/Demo/rtmpdump/rtmpdump/librtmp'updates
/usr/include/openssl/opensslconf.h:31:2: error: #error "This openssl-devel package does not work your architecture?"
#error "This openssl-devel package does not work your architecture?"
[root@demo rtmpdump]# rpm -qa|grep ssl
openssl-devel-1.0.1e-30.el6.11.x86_64
openssl-1.0.1e-30.el6.11.x86_64
docbook-style-dsssl-1.79-10.el6.noarch
[root@demo rtmpdump]# rpm -e --nodeps openssl-devel-1.0.1e-30.el6.11.x86_64
[root@demo rtmpdump]# rpm -qa|grep ssl
openssl-1.0.1e-30.el6.11.x86_64
docbook-style-dsssl-1.79-10.el6.noarch
[root@demo rtmpdump]# rpm -e --nodeps openssl-1.0.1e-30.el6.11.x86_64
[root@demo rtmpdump]# rpm -qa|grep ssl
docbook-style-dsssl-1.79-10.el6.noarch
[root@demo rtmpdump]#
/usr/include/bits/socket.h:427:23: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
rtmp.c:60:25: fatal error: openssl/ssl.h: No such file or directory
#include <openssl/ssl.h>
[root@demo rtmpdump]# make SYS=posix CROSS_COMPILE=arm-hisiv300-linux- INC=-I/home/srs/simple-rtmp-server/trunk/objs/openssl-1.0.1f/include/
make[1]: Entering directory `/home/Hi3516A/Demo/rtmpdump/rtmpdump/librtmp'
arm-hisiv300-linux-gcc -Wall -I/home/srs/simple-rtmp-server/trunk/objs/openssl-1.0.1f/include/ -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o rtmp.o rtmp.c
rtmp.c: In function ‘RTMP_ReadPacket’:
rtmp.c:3552:7: warning: variable ‘didAlloc’ set but not used [-Wunused-but-set-variable]
int didAlloc = FALSE;
^
arm-hisiv300-linux-gcc -Wall -I/home/srs/simple-rtmp-server/trunk/objs/openssl-1.0.1f/include/ -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o log.o log.c
arm-hisiv300-linux-gcc -Wall -I/home/srs/simple-rtmp-server/trunk/objs/openssl-1.0.1f/include/ -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o amf.o amf.c
arm-hisiv300-linux-gcc -Wall -I/home/srs/simple-rtmp-server/trunk/objs/openssl-1.0.1f/include/ -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o hashswf.o hashswf.c
hashswf.c:69:18: fatal error: zlib.h: No such file or directory
#include <zlib.h>
^
compilation terminated.
make[1]: *** [hashswf.o] Error 1
make[1]: Leaving directory `/home/Hi3516A/Demo/rtmpdump/rtmpdump/librtmp'
make: *** [librtmp/librtmp.a] Error 2
[root@demo rtmpdump]#
cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.so.1.2.8 /usr/local/lib
chmod 755 /usr/local/lib/libz.so.1.2.8
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
3.直接进行编译rtmpdump是不可行的,缺少openssl的支持
系统环境:CentOS 6.5 64位
OpenSSL源码包:http://www.openssl.org/source/openssl-1.0.1f.tar.gz
安装zlib库支持:
cd /usr/local/src
wget http://zlib.net/zlib-1.2.5.tar.gz
tar zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5 www.111cn.net
./configure && make && make install
安装OpenSSL源码包:wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
tar zxvf openssl-1.0.1f
cd openssl-1.0.1f/
CC=arm-linux-gcc ./config no-asm shared --prefix=/opt/toolchains/arm-jyxtec-linux-gnueabi/arm-jyxtec-linux-gnueabi/
--prefix请自行指定
参数 : shared 是生成动态连接库, –prefix 为安装目录,openssldir 是配置文件目录。
这样生成的Makefile是不用修改的,直接
[root@demo zlib-1.2.8]# CC=arm-hisiv300-linux-gcc ./config no-asm shared --prefix=/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib
[root@demo openssl-1.0.1p]#make
4.交叉编译zlib
[root@demo zlib-1.2.8]# wget http://zlib.net/zlib-1.2.8.tar.gz
[root@demo zlib-1.2.8]# CC=arm-hisiv300-linux-gcc ./configure --prefix=/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib
[root@demo zlib-1.2.8]# make
[root@demo zlib-1.2.8]# make install
ln -s libz.so.1.2.8 libz.so
ln -s libz.so.1.2.8 libz.so.1
arm-hisiv300-linux-gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o examplesh example.o -L. libz.so.1.2.8
arm-hisiv300-linux-gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o minigzipsh minigzip.o -L. libz.so.1.2.8
arm-hisiv300-linux-gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -D_FILE_OFFSET_BITS=64 -c -o example64.o test/example.c
arm-hisiv300-linux-gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o example64 example64.o -L. libz.a
arm-hisiv300-linux-gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -D_FILE_OFFSET_BITS=64 -c -o minigzip64.o test/minigzip.c
arm-hisiv300-linux-gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o minigzip64 minigzip64.o -L. libz.a
[root@demo zlib-1.2.8]#
[root@demo zlib-1.2.8]# make install
cp libz.a /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/lib
chmod 644 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/lib/libz.a
cp libz.so.1.2.8 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/lib
chmod 755 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/lib/libz.so.1.2.8
cp zlib.3 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/share/man/man3
chmod 644 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/share/man/man3/zlib.3
cp zlib.pc /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/lib/pkgconfig
chmod 644 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/include
chmod 644 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/include/zlib.h /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/include/zconf.h
5.交叉编译rtmpdump
[root@demo openssl-1.0.1p]# cp /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/include/* include/ -f
[root@demo openssl-1.0.1p]# ls in
include/ install.com
[root@demo openssl-1.0.1p]# ls include/
openssl zconf.h zlib.h
[root@demo openssl-1.0.1p]#
[root@demo rtmpdump]# make SYS=posix CROSS_COMPILE=arm-hisiv300-linux- INC=-I/home/Hi3516A/demo/openssl-1.0.1p/include/
make[1]: Entering directory `/home/Hi3516A/demo/rtmpdump/librtmp'
arm-hisiv300-linux-gcc -Wall -I/home/Hi3516A/demo/openssl-1.0.1p/include/ -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o hashswf.o hashswf.c
arm-hisiv300-linux-gcc -Wall -I/home/Hi3516A/demo/openssl-1.0.1p/include/ -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o parseurl.o parseurl.c
arm-hisiv300-linux-ar rs librtmp.a rtmp.o log.o amf.o hashswf.o parseurl.o
arm-hisiv300-linux-ar: creating librtmp.a
arm-hisiv300-linux-gcc -shared -Wl,-soname,librtmp.so.1 -o librtmp.so.1 rtmp.o log.o amf.o hashswf.o parseurl.o -lssl -lcrypto -lz
/opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/../lib/gcc/arm-hisiv300-linux-uclibcgnueabi/4.8.3/../../../../arm-hisiv300-linux-uclibcgnueabi/bin/ld: cannot find -lssl
/opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/../lib/gcc/arm-hisiv300-linux-uclibcgnueabi/4.8.3/../../../../arm-hisiv300-linux-uclibcgnueabi/bin/ld: cannot find -lcrypto
/opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin/../lib/gcc/arm-hisiv300-linux-uclibcgnueabi/4.8.3/../../../../arm-hisiv300-linux-uclibcgnueabi/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make[1]: *** [librtmp.so.1] 错误 1
make[1]: Leaving directory `/home/Hi3516A/demo/rtmpdump/librtmp'
make: *** [librtmp/librtmp.a] 错误 2
[root@demo rtmpdump]#
[root@demo openssl-1.0.1p]# cp libssl.so.1.0.0 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/arm-hisiv300-linux-uclibcgnueabi/lib
[root@demo openssl-1.0.1p]# cp libcrypto.so.1.0.0 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/arm-hisiv300-linux-uclibcgnueabi/lib
[root@demo openssl-1.0.1p]#
[root@demo lib]# pwd
/opt/hisi-linux/x86-arm/arm-hisiv300-linux/arm-hisiv300-linux-uclibcgnueabi/lib
[root@demo lib]# ln -s libcrypto.so.1.0.0 libcrypto.so
[root@demo openssl-1.0.1p]# cd /opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib/
[root@demo lib]# cd lib
[root@demo lib]# ls
libz.a libz.so libz.so.1 libz.so.1.2.8 pkgconfig
[root@demo lib]# cp libz.so.1.2.8 /opt/hisi-linux/x86-arm/arm-hisiv300-linux/arm-hisiv300-linux-uclibcgnueabi/lib
[root@demo lib]# ln -s libz.so.1.2.8 libz.so
[root@demo lib]# ln -s libz.so.1.2.8 libz.so.1
[root@demo rtmpdump]# make SYS=posix CROSS_COMPILE=arm-hisiv300-linux- INC=-I/home/Hi3516A/demo/openssl-1.0.1p/include/
//总结:
主要依赖zlib、openssl,需要对以上两库进行交叉编译,
将libz.so.1.2.8、libcrypto.so.1.0.0、libssl.so.1.0.0拷贝到/opt/hisi-linux/x86-arm/arm-hisiv300-linux/arm-hisiv300-linux-uclibcgnueabi/lib
6.交叉编译rtmpdump(第5 步骤交叉编译librtmp)
要使用最新的librtmp.a librtmp.so.1
[root@demo librtmp]# vi Makefile
[root@demo librtmp]# cp ../rtmpdump/librtmp/librtmp.a ./librtmp
[root@demo librtmp]# make clean all SYS=posix CROSS_COMPILE=arm-hisiv300-linux- INC=-I/home/Hi3516A/demo/openssl-1.0.1p/include/