ZLMediaKit是一套高性能的流媒体服务框架,目前支持rtmp、rtsp、hls、http-flv等流媒体协议,支持linux、macos、windows三大PC平台和ios、android两大移动端平台。
host主机:ubuntu18.04
移植平台:rk3568
交叉编译链版本:gcc version 9.3.0
https://github.com/ZLMediaKit/ZLMediaKit
1,下载源码(github地址 GitHub - ZLMediaKit/ZLMediaKit: WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181/SRT server and client framework based on C++11)
#国内用户推荐从同步镜像网站gitee下载
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
#千万不要忘记执行这句命令
git submodule update --init
2,创建cmake编译文件
在命令行执行以下命令,CMAKE_SYSTEM_NAME设置系统平台,CMAKE_SYSTEM_PROCESSOR设置处理器架构为aarch64,CMAKE_STAGING_PREFIX为安装路径,CMAKE_C_COMPILER设置gcc工具链位置,CMAKE_CXX_COMPILER设置g++工具链的位置。cat /tmp/toolchain.cmake查看是否写入。
cat > /tmp/toolchain.cmake <<'EOT'
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_STAGING_PREFIX /home/bsp/rp_3568/ZLinstall)
set(CMAKE_C_COMPILER /home/bsp/rp_3568/rk3566-rk3568-linux/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/bin/aarch64-linux-gcc)
set(CMAKE_CXX_COMPILER /home/bsp/rp_3568/rk3566-rk3568-linux/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/bin/aarch64-linux-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
EOT
4,cmake配置
mkdir build_arm
cd build_arm
cmake -DCMAKE_TOOLCHAIN_FILE=/tmp/toolchain.cmake -DCMAKE_INSTALL_PREFIX=/home/bsp/rp_3568/ZLinstall ..
提示 not able to compile a simple test program,仔细看是缺少库 error while loading shared libraries: libisl.so.15: cannot open shared object file: No such file or directory。
bsp@zmjbsp:/usr/lib$ find -name "libisl.so*"
./x86_64-linux-gnu/libisl.so.19
./x86_64-linux-gnu/libisl.so.19.0.0
bsp@zmjbsp:/usr/lib$
搜索这个库,可以找到但是不是那个版本的,软链接一下
sudo ln -s /usr/lib/x86_64-linux-gnu/libisl.so.19 /usr/lib/x86_64-linux-gnu/libisl.so.15
修改后这个库好了,下面又提示 error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory,再链接一下,再cmake那条指令检查成功了。
sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4
5,编译安装
make -j4 install
编译中报错了,/usr/local/lib/libssl.so: error adding symbols: File in wrong format,它找的是主机中的libssl.so而不是arm中的。
在cmake时,也发现了确实是主机里的。在交叉编译链中能找到libssl.so,我们在cmake指定一下libssl.so的位置,运行后编译成功。(注意:清除一下build_arm和release里面的编译缓存)
cmake -DCMAKE_TOOLCHAIN_FILE=/tmp/toolchain.cmake -DCMAKE_INSTALL_PREFIX=/home/bsp/rp_3568/ZLinstall -DOPENSSL_LIBRARIES=/home/bsp/rp_3568/rk3566-rk3568-linux/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib -DOPENSSL_ROOT_DIR=/home/bsp/rp_3568/rk3566-rk3568-linux/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu ..
6,在板子上运行
因为是静态库编译的,只需把MediaServer这个bin文件拷贝到板子上即可。