美文网首页
Nginx+RTMP module 移植Hi3516DV300

Nginx+RTMP module 移植Hi3516DV300

作者: 沙场点将 | 来源:发表于2019-10-16 15:08 被阅读0次

一、简介

需要在海思开发板上提供HTTP服务和RTMP服务,所以就需要移植。X86上面的都还没有整太明白所以过程中很多问题,慢慢解决吧。

开始移植

1)下载源文件

为了方便使用我就都放在一个路径下了,在下面路径了找到你想用的版本。我就按照最新的版本下载了
Nginx 下载地址:http://nginx.org/download/
pcre 下载地址:https://ftp.pcre.org/pub/pcre/
OpenSSL下载地址:https://www.openssl.org/source/
Nginx-rtmp 下载地址:https://github.com/arut/nginx-rtmp-module/releases
下面是我下载的版本:

wget http://nginx.org/download/nginx-1.17.4.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz

强迫症所以有了下面的代码:

mv v1.2.1.tar.gz nginx-rtmp-module-1.2.1.tar.gz
下载过程截图
下载过程截图
下载过程截图
下载过程截图以及重命名后

2)解压文件

直接解压到当前文件就OK了。没什么好说的直接上代码:

tar zxvf nginx-1.17.4.tar.gz 
tar zxvf nginx-rtmp-module-1.2.1.tar.gz 
tar zxvf openssl-1.1.1d.tar.gz 
tar zxvf pcre-8.43.tar.gz

3)配置编译文件

首先配置环境变量:

export BUILD_PATH=$PWD
export INSTALL_PATH=/opt/nginx
export CC_PATH=/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-gcc
export CPP_PATH=/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-g++
export CONFIG_DIR=/opt/nginx/conf
export LOG_DIR=/opt/nginx/log
export TEMP_DIR=/opt/nginx/tmp

变量说明:
INSTALL_PATH:安装路径,该路径随便修改
CC_PATH:对应平台gcc
CPP_PATH:对应平台g++
CONFIG_DIR:配置文件生成路径
LOG_DIR:日志文件生成路径
TEMP_DIR:tmp文件生成路径

配置编译选项:

./configure --prefix=$INSTALL_PATH \
            --conf-path=$CONFIG_DIR/nginx.conf \
            --error-log-path=$LOG_DIR/error.log \
            --pid-path=$CONFIG_DIR/nginx.pid \
            --lock-path=$CONFIG_DIR/nginx.lock \
            --http-log-path=$LOG_DIR/access.log \
            --http-client-body-temp-path=$TEMP_DIR/body \
            --http-proxy-temp-path=$TEMP_DIR/proxy \
            --http-fastcgi-temp-path=$TEMP_DIR/fastcgi \
            --without-http_uwsgi_module \
            --without-http_scgi_module \
            --without-http_gzip_module \
            --with-http_ssl_module \
            --add-module=/home/jinsai/Share/Ajs/opensource/nginx-rtmp-module-1.2.1 \
            --with-pcre=/home/jinsai/Share/Ajs/opensource/pcre-8.43 \
            --with-openssl=/home/jinsai/Share/Ajs/opensource/openssl-1.1.1d \
            --without-http_upstream_zone_module --with-cc=$CC_PATH \
            --with-cpp=$CPP_PATH \
            --with-cc-opt="-I /opt/hisi-linux/x86-arm/arm-himix200-linux/target/sbin" \
            --with-ld-opt="-L /opt/hisi-linux/x86-arm/arm-himix200-linux/target/lib"

上面变量含义请参考:https://www.nginx.com/resources/wiki/start/topics/tutorials/installoptions/

4)遇到问题

问题1:

现象:


错误截图

原因:
configure首先会编译一个小测试程序,通过测试其运行结果来判断编译器是否能正常工作,由于交叉编译器所编译出的程序是无法在编译主机上运行的,故而产生此错误。
解决办法:
vi auto/cc/name文件,将21行的“exit 1”注释掉


auto/cc/name

问题2:

现象:

autotest : 4 : not found 
autotest:Syntax error: Unterminated quoted string bytes 
./configure : error:can not detect int size

原因:
configure通过运行测试程序来获得“int、long、longlong”等数据类型的大小,由于交叉编译器所编译出的程序无法在编译主机上运行而产生错误。
解决方法:
直接打开 auto/types/sizeof 这个测试文件 修改下图红框的内容指定大小为4字节就行了


auto/types/sizeof

问题3

现象

checking whether we are cross compiling... configure: error: in `/home/jinsai/Share/Ajs/opensource/pcre-8.43':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
make[1]: *** [/home/jinsai/Share/Ajs/opensource/pcre-8.43/Makefile] 错误 1

原因:
编译 pcre 没有指定 `--host' 参数
解决方法:
vi objs/Makefile,找到 pcre 参数设定的那几行修改如下图:


objs/Makefile

问题4

现象:

error: unrecognized command line option '-m64'

原因:
按照一般移植的文档执行完config后去掉所有-m64就行了。但是这个方法不适用现在。具体原因是我们的编译器是32位平台的。所以在config指示为32位就可以。还需要使用Configure来组件工程
解决方法:
vi objs/Makefile,找到 openssl参数设定的那几行修改如下图:


image.png

问题5

现象:

src/os/unix/ngx_errno.c: In function 'ngx_strerror':
src/os/unix/ngx_errno.c:37: error: 'NGX_SYS_NERR' undeclared (first use in this function)
src/os/unix/ngx_errno.c:37: error: (Each undeclared identifier is reported only once
src/os/unix/ngx_errno.c:37: error: for each function it appears in.)
src/os/unix/ngx_errno.c: In function 'ngx_strerror_init':
src/os/unix/ngx_errno.c:58: error: 'NGX_SYS_NERR' undeclared (first use in this function)

原因:
NGX_SYS_NERR未定义,NGX_SYS_NERR正常情况下应定义在objs/ngx_auto_config.h文件中,特别注意,这是一个auto性质的文件,只有在执行了./configure后,才能生成这个文件。宏NGX_SYS_NERR的意义为,在Linux系统中有132个错误编码。
解决方法:
vi objs/ngx_auto_config.h 打开这个文件 增加如下参数:


image.png

NGX_HAVE_SYSVSHM 是undefined reference to `ngx_shm_free' 错误的。同时也加上吧。

相关文章

网友评论

      本文标题:Nginx+RTMP module 移植Hi3516DV300

      本文链接:https://www.haomeiwen.com/subject/pjvymctx.html