欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

海思3531D移植srs-2.0.269 st库引发段错误

程序员文章站 2022-06-11 15:53:26
...

海思3531D移植srs-2.0.269 st库引发段错误

一、环境

1.交叉编译工具链:arm-hisiv600-linux-gcc,版本4.9.4,glibc-2.2.0
2.srs-2.0.269下载地址:https://github.com/ossrs/srs.git
3.st-1.9修正版本下载地址:https://github.com/ossrs/state-threads.git
4.官方相关issue:https://github.com/ossrs/srs/issues/1282

二、引发的主要报错

海思3531D移植srs-2.0.269 st库引发段错误海思3531D移植srs-2.0.269 st库引发段错误
可以初步定为为st-1.9与glibc兼容的问题

三、步骤

1.安装交叉编译工具链(略)
2.下载srs-2.0.269

git clone -b 2.0release https://github.com/ossrs/srs.git
cd srs/trunk

3.修改srs相关setup_variables.sh

vim auto/setup_variables.sh 

if [ $SRS_ARM_UBUNTU12 = YES ]; then
__SrsArmCC=“arm-linux-gnueabi-gcc”;
__SrsArmGCC=“arm-linux-gnueabi-gcc”;
__SrsArmCXX=“arm-linux-gnueabi-g++”;
__SrsArmAR=“arm-linux-gnueabi-ar”;
__SrsArmLD=“arm-linux-gnueabi-ld”;
__SrsArmRANDLIB=“arm-linux-gnueabi-ranlib”;
fi
更改为海思3531D工具链
if [ $SRS_ARM_UBUNTU12 = YES ]; then
__SrsArmCC=“arm-hisiv600-linux-gcc”;
__SrsArmGCC=“arm-hisiv600-linux-gcc”;
__SrsArmCXX=“arm-hisiv600-linux-g++”;
__SrsArmAR=“arm-hisiv600-linux-ar”;
__SrsArmLD=“arm-hisiv600-linux-ld”;
__SrsArmRANDLIB=“arm-hisiv600-linux-ranlib”;
fi

4.下载编译st-1.9修正版本,并进行相关操作

git clone -b srs https://github.com/ossrs/state-threads.git
//变更文件夹名
mv state-threads st-1.9
//压缩文件夹为zip
zip -r st-1.9.zip st-1.9
//将zip文件替换srs原始的文件
mv st-1.9.zip srs/trunk/3rdparty
//打开 depends.sh  422行
vim srs/trunk/auto/depends.sh 

echo “build st-1.9t for arm”;
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q …/3rdparty/st-1.9.zip && cd st-1.9 && chmod +w * &&
patch -p0 < …/…/3rdparty/patches/1.st.arm.patch &&
patch -p0 < …/…/3rdparty/patches/3.st.osx.kqueue.patch &&
patch -p0 < …/…/3rdparty/patches/4.st.disable.examples.patch &&
patch -p0 < …/…/3rdparty/patches/6.st.osx10.14.build.patch &&
make STMAKECC={_ST_MAKE} CC={SrsArmCC} AR=SrsArmARLD={SrsArmAR} LD={SrsArmLD} RANDLIB=SrsArmRANDLIBEXTRACFLAGS="{SrsArmRANDLIB} EXTRA_CFLAGS="{_ST_EXTRA_CFLAGS}" &&
cd … && rm -rf st && ln -sf st-1.9/obj st &&
cd … && touch ${SRS_OBJS}/_flag.st.cross.build.tmp
)
将这段替换为,主要是删除patch操作,因为修正版本不需要再patch
echo “build st-1.9t for arm”;
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q …/3rdparty/st-1.9.zip && cd st-1.9 && chmod +w * &&
make STMAKECC={_ST_MAKE} CC={SrsArmCC} AR=SrsArmARLD={SrsArmAR} LD={SrsArmLD} RANDLIB=SrsArmRANDLIBEXTRACFLAGS="{SrsArmRANDLIB} EXTRA_CFLAGS="{_ST_EXTRA_CFLAGS}" &&
cd … && rm -rf st && ln -sf st-1.9/obj st &&
cd … && touch ${SRS_OBJS}/_flag.st.cross.build.tmp
)

5.配置运行编译脚本

PKG_CONFIG_PATH=/交叉编译库依赖路径/pkgconfig \
CC=arm-hisiv600-linux-gcc \ 
CFLAGS="${CFLAGS} -mcpu=cortex-a9 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations" \ 
CXX=arm-hisiv600-linux-g++ \
CXXFLAGS="${CXXFLAGS} -mcpu=cortex-a9 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations"\
./configure \
 --with-arm-ubuntu12 \
 --prefix=/目标路径 \
 --with-http-api \
 --with-http-callback \
 --with-http-server \
 --with-hls 

执行后会开始编译相关depends,成功后如下所示
海思3531D移植srs-2.0.269 st库引发段错误
5.修改srs_librtmp、objst相关

vim srs/trunk/research/librtmp/Makefile

将第1行 GCC = gcc
改为 GCC = arm-hisiv600-linux-gcc
将第62行改为 ifeq ($(GCC), arm-hisiv600-linux-gcc)

vim srs/trunk/objs/Makefile

GCC = gcc
CXX = g++
AR = ar
LINK = g++
改为
GCC = arm-hisiv600-linux-gcc
CXX = arm-hisiv600-linux-g++
AR = arm-hisiv600-linux-ar
LINK = arm-hisiv600-linux-g++

5.执行make && make install

make && make install	

海思3531D移植srs-2.0.269 st库引发段错误
6.将生成的conf etc objs 拷贝到开发板上运行

./objs/srs -c conf/srs.conf

至此所有报错消失
海思3531D移植srs-2.0.269 st库引发段错误

四、测试

海思3531D移植srs-2.0.269 st库引发段错误

五、相关博客

在海思hisiv100nptl平台上交叉编译并安装SRS
感谢杨工和相关同行所做的指导

相关标签: 移植