一、编译环境及准备材料
1、编译环境:
1.1、ubuntu 14.04.1
$ uname -a Linux ubuntu 4.4.0-128-generic #154~14.04.1-Ubuntu SMP Fri May 25 14:58:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
1.2、交叉编译器
$ arm-hisiv100nptl-linux-gcc -v Using built-in specs. Target: arm-hisiv100-linux-uclibcgnueabi Configured with: ../gcc-4.4-2010q1/configure --host=i486-linux-gnu --build=i486-linux-gnu --target=arm-hisiv100-linux-uclibcgnueabi --prefix=/home/sying/uclibc_h3/hisiv100_finalnptl_src/hisiv100_src/install/arm-hisiv100-linux ... ... Thread model: posix gcc version 4.4.1 (Hisilicon_v100(gcc4.4-290+uclibc_0.9.32.1+eabi+linuxpthread))
2、openssl 源码
openssl 官网源码下载
openssl有提供旧版本源码下载,我这里下载的是 openssl-1.1.0l.tar.gz
3、live555库
live555官网源码下载路径
在官网下载源码时,没有提供旧版本的源码,我下载的是最新的发布版 live.2022.01.06.tar.gz
二、编译openssl
1、创建目录用来安装openssl,解压openssl源码包 openssl-1.1.0l.tar.gz,并进入源码目录
$ mkdir ssl_result $ tar zxvf openssl-1.1.0l.tar.gz $ cd openssl-1.1.0l
2、指定安装目录、交叉编译器,命令如下
./config no-asm shared no-async --prefix=/home/samba/live555/ssl_result --cross-compile-prefix=arm-hisiv100nptl-linux-
关于 no-asm shared no-async 的注释,详见 openssl编译参数选项
3、修改Make file,删除 -m64,可以在Makefile去搜索删除,共两处,也可以使用以下命令删除
sed -i 's/-m64//' Makefile
4、编译、安装,命令如下
make && make install
完成后,在刚才创建的 ssl_result 目录下有如下文件,编译live555时需要用到
$ ls ../ssl_result bin include lib share ssl
编译 openssl 遇到问题,可以看这 openssl 的编译和交叉编译
三、编译live555
1、解压代码
将live555源码压缩包复制到前面创建的 ssl_result同一
目录下,解压缩后, 进入live 文件夹。
$ tar zxvf live.2022.01.06.tar.gz $ cd live
2、生成Makefile并编译,报错
2.1、利用config.armlinux文件来生成Makefile,先复制config.armlinux为config.3531A
cp config.armlinux config.3531A
原来的config.armlinux的文件内容如下:
CROSS_COMPILE?= arm-elf- COMPILE_OPTS = $(INCLUDES) -I/usr/local/include -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 C = c C_COMPILER = $(CROSS_COMPILE)gcc C_FLAGS = $(COMPILE_OPTS) CPP = cpp CPLUSPLUS_COMPILER = $(CROSS_COMPILE)g++ CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1 OBJ = o LINK = $(CROSS_COMPILE)g++ -o LINK_OPTS = CONSOLE_LINK_OPTS = $(LINK_OPTS) LIBRARY_LINK = $(CROSS_COMPILE)ar cr LIBRARY_LINK_OPTS = $(LINK_OPTS) LIB_SUFFIX = a LIBS_FOR_CONSOLE_APPLICATION = -lssl -lcrypto LIBS_FOR_GUI_APPLICATION = EXE =
修改交叉编译器、指定openssl的头文件和库文件后,config.3531A内容如下:
CROSS_COMPILE?= arm-hisiv100nptl-linux- COMPILE_OPTS = $(INCLUDES) -I/home/samba/live555/ssl_result/include -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 C = c C_COMPILER = $(CROSS_COMPILE)gcc C_FLAGS = $(COMPILE_OPTS) CPP = cpp CPLUSPLUS_COMPILER = $(CROSS_COMPILE)g++ CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1 OBJ = o LINK = $(CROSS_COMPILE)g++ -o LDFLAGS= -L /home/samba/live555/ssl_result/lib LINK_OPTS = $(LDFLAGS) CONSOLE_LINK_OPTS = $(LINK_OPTS) LIBRARY_LINK = $(CROSS_COMPILE)ar cr LIBRARY_LINK_OPTS = LIB_SUFFIX = a LIBS_FOR_CONSOLE_APPLICATION = -lssl -lcrypto LIBS_FOR_GUI_APPLICATION = EXE =
2.2、执行命令生成Makefile
./genMakefiles linux
2.3、编译后,报如下错误:
$ ./genMakefiles linux $ make ... ... arm-hisiv100nptl-linux-g++ -otestMP3Streamer -L /home/samba/live555/ssl_result/lib testMP3Streamer.o announceURL.o ../liveMedia/libliveMedia.a ../groupsock/libgroupsock.a ../BasicUsageEnvironment/libBasicUsageEnvironment.a ../UsageEnvironment/libUsageEnvironment.a -lssl -lcrypto /home/samba/live555/ssl_result/lib/libcrypto.so: warning: gethostbyname is obsolescent, use getnameinfo() instead. ../liveMedia/libliveMedia.a(Locale.o): In function `Locale::~Locale()': Locale.cpp:(.text+0x20): undefined reference to `uselocale' Locale.cpp:(.text+0x28): undefined reference to `freelocale' ../liveMedia/libliveMedia.a(Locale.o): In function `Locale::~Locale()': Locale.cpp:(.text+0x58): undefined reference to `uselocale' Locale.cpp:(.text+0x60): undefined reference to `freelocale' ../liveMedia/libliveMedia.a(Locale.o): In function `Locale::~Locale()': Locale.cpp:(.text+0x90): undefined reference to `uselocale' Locale.cpp:(.text+0x98): undefined reference to `freelocale' ../liveMedia/libliveMedia.a(Locale.o): In function `Locale::Locale(char const*, LocaleCategory)': Locale.cpp:(.text+0xd0): undefined reference to `newlocale' Locale.cpp:(.text+0xd8): undefined reference to `uselocale' ../liveMedia/libliveMedia.a(Locale.o): In function `Locale::Locale(char const*, LocaleCategory)': Locale.cpp:(.text+0x10c): undefined reference to `newlocale' Locale.cpp:(.text+0x114): undefined reference to `uselocale' collect2: ld returned 1 exit status make[1]: *** [testMP3Streamer] Error 1 make[1]: Leaving directory `/home/samba/live555/live/testProgs' make: *** [all] Error 2
3、问题分析
查看错误,uselocale 等函数没有定义,使用grep命令搜索了 openssl 源码目录和 live555源码目录,都没有对 uselocale 函数的定义,所以这个函数可能自其他的库,也可能属于系统函数,包含在编译工具里,而这个交叉工具链没有该函数。
在源码里查看调用这个函数的类,在定义该类的头文件 Locale.hh 中发现有下面这个注释,意思是:如果您使用的系统(无论出于何种原因)没有“setlocale()”或“newlocale()”函数,则将“-DLOCALE_NOT_USED”添加到“config.*”文件中。
// If you're on a system that (for whatever reason) doesn't have either the "setlocale()" or the "newlocale()" function, then // add "-DLOCALE_NOT_USED" to your "config.*" file.
4、问题解决
根据Locale.hh的要求,我们在 config.3531A 中添加 “-DLOCALE_NOT_USED”,修改后如下:
CROSS_COMPILE?= arm-hisiv100nptl-linux- COMPILE_OPTS = $(INCLUDES) -I/home/samba/live555/ssl_result/include -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOCALE_NOT_USED C = c C_COMPILER = $(CROSS_COMPILE)gcc C_FLAGS = $(COMPILE_OPTS) CPP = cpp CPLUSPLUS_COMPILER = $(CROSS_COMPILE)g++ CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1 OBJ = o LINK = $(CROSS_COMPILE)g++ -o LDFLAGS= -L /home/samba/live555/ssl_result/lib LINK_OPTS = $(LDFLAGS) CONSOLE_LINK_OPTS = $(LINK_OPTS) LIBRARY_LINK = $(CROSS_COMPILE)ar cr LIBRARY_LINK_OPTS = LIB_SUFFIX = a LIBS_FOR_CONSOLE_APPLICATION = -lssl -lcrypto LIBS_FOR_GUI_APPLICATION = EXE =
再次生成Makefile,编译通过
$ ./genMakefiles 3531A $ make clean $ make
四、运行 live555MediaServer
1、运行 live555MediaServer
编译完成后,从live555官网下载一个264文件(test.264),并将 test.264、ssl_result、mediaServer目录下的 live555MediaServer 三个东西一起复制到arm板子上
cp /home/samba/test.264 ./mediaServer/live555MediaServer ../ssl_result /nfsroot/ -rf
然后,进入板子操作
添加动态库加载路径 LD_LIBRARY_PATH,运行 live555MediaServer,过程如下:
/nfsroot # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/nfsroot/ssl_result/lib /nfsroot # ./live555MediaServer LIVE555 Media Server version 1.10 (LIVE555 Streaming Media library version 2022.01.06). Play streams from this server using the URL rtsp://192.168.2.100:8554/<filename> where <filename> is a file present in the current directory. Each file's type is inferred from its name suffix: ".264" => a H.264 Video Elementary Stream file ".265" => a H.265 Video Elementary Stream file ".aac" => an AAC Audio (ADTS format) file ".ac3" => an AC-3 Audio file ".amr" => an AMR Audio file ".dv" => a DV Video file ".m4e" => a MPEG-4 Video Elementary Stream file ".mkv" => a Matroska audio+video+(optional)subtitles file ".mp3" => a MPEG-1 or 2 Audio file ".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file ".ogg" or ".ogv" or ".opus" => an Ogg audio and/or video file ".ts" => a MPEG Transport Stream file (a ".tsx" index file - if present - provides server 'trick play' support) ".vob" => a VOB (MPEG-2 video with AC-3 audio) file ".wav" => a WAV Audio file ".webm" => a WebM audio(Vorbis)+video(VP8) file See http://www.live555.com/mediaServer/ for additional documentation. (We use port 80 for optional RTSP-over-HTTP tunneling).)
运行live555MediaServer时有打印所有支持的格式,只要将对应格式的合法文件复制到运行 live555MediaServer 的目录,都可以通过vlc来访问。
2、使用 vlc 来打开rtsp流
在vlc菜单“媒体”->"打开网络串流"->"打开媒体",输入你对应的地址(运行 live555MediaServer 打印的ip和端口和 live555MediaServer 目录下对应的媒体文件)就可以访问到流,我这里的流地址是:rtsp://192.168.2.100:8554/test.264
到此,编译结束,如果对你有帮助的话,点赞支持一下^_^