bbenben08 2019-07-23 10:37:46 100 已收藏
展开
这里记录一下所遇到的问题。
下载pcre,openssl,nginx源码解压到同级目录。
在此先列下我使用各源码的版本,以免在目标板运行时还是有问题
nginx-1.4.7(可能是我的芯片为32位A9 处理器,开始时用了nginx-1.8版本,按照下面的流程编译通过,但运行有问题,后来改为nginx-1.4.7就可以正常运行了)
openssl-1.0.1s
pcre-8.39
zlib-1.2.11
配置环境变量:
export INSTALL_PATH=/usr/local/nginx //安装路径会写入nginx可执行程序
export CC_PATH=/var/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu-gcc
export CPP_PATH=/var/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu-g++
配置configure:
./configure --prefix=$INSTALL_PATH \
--with-http_ssl_module \
--with-pcre=/home/pcre-8.36 \
--with-zlib=/home/zlib-1.2.7 \
--with-openssl=/home/openssl-1.0.2s \
--with-cc=$CC_PATH \
--with-cpp=$CPP_PATH
--add-module=/home/nginx-rtmp-module-master
如需要加上nginx-rtmp-module 则如上加上此模块源码一起编译即可
编译:
make;make install
遇到的问题
这里补上漏掉的问题:
configure错误:
1
checking for C compiler ... found but is not working
./configure: error: C compiler arm-hisiv400-linux-gcc is not found
vi auto/cc/name ,找到
if [ $ngx_found = no ]; then
echo
echo $0: error: C compiler $CC is not found
echo
exit 1
fi
configure首先会编译一个小测试程序,通过测试其运行结果来判断编译器是否能正常工作,由于交叉编译器所编译出的程序是无法在编译主机上运行的,故而产生此错误。exit 1 注释掉。
2
autotest:Syntax error: Unterminated quoted string bytes
./configure : error:can not detect int size
出现这个错误是因为使用交叉编译器直接测试在host上是运行不了,因此把 $CC 改为 gcc
vi auto/types/sizeof ,
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS
改为
ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS
ngx_size=$NGX_AUTOTEST
修改为 ngx_size=4
make错误:
3
src/core/ngx_rwlock.c:125:2: error: #error ngx_atomic_cmp_set() is not defined!
这个错误需要将 configure时 加入–without-http_upstream_zone_module参数。
1
pcre没有指定host。在nginx/objs/Makefile 修改
/home/pcre-8.36/Makefile: objs/Makefile
cd /home/pcre-8.36 \
&& if [ -f Makefile ]; then $(MAKE) distclean; fi \
&& CC="$(CC)" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared
最后一行增加 --host=aarch64-linux-gnu。
2
看提示是在unix系统openssl需要使用config而不是Configure。修改nginx/objs/Makefile
/home/openssl-1.0.2s/.openssl/include/openssl/ssl.h: objs/Makefile
cd /home/openssl-1.0.2s \
&& if [ -f Makefile ]; then $(MAKE) clean; fi \
&& ./Configure --prefix=/home/openssl-1.0.2s/.openssl no-shared no-threads --cross-compile-prefix=/var/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu- \
&& $(MAKE) \
&& $(MAKE) install_sw LIBDIR=lib
将Configure改为config。(此处可能有的版本已经修改,而且自动编译成功,但会使用了x86 的gcc 编译,因此还是需要按照上面写的修改,并且加上no-asm ,下面有提到)
3
-m64 是64位操作系统,但是不知道为什么我的编译器识别不了,所以只能到openssl文件夹单独编译openssl。需要删除openssl的Makefile中所有 -m64 的地方,有两处。SHARED_LDFLAGS=-m64这里整行删除。
4
这个需要修改nginx/objs/Makefile , 第2个问题中config行增加 no-asm ,禁用汇编。重新make,再到openssl文件夹修改Makefile后make;make install,回到nginx文件夹重新make
5
需要修改 objs/ngx_auto_config.h,增加
#ifndef NGX_SYS_NERR
#define NGX_SYS_NERR 132
#endif
这个问题需要修改相同位置
#ifndef NGX_HAVE_SYSVSHM
#define NGX_HAVE_SYSVSHM 1
#endif
make成功后make install 安装到设置的安装目录。
另外,我所使用的版本的nginx 编译过程中还遇到如下问题
src/core/ngx_string.c: In function ‘ngx_atoi’:
src/core/ngx_string.c:910:5: error: overflow in implicit constant conversion [-Werror=overflow]
src/core/ngx_string.c: In function ‘ngx_atofp’:
src/core/ngx_string.c:941:5: error: overflow in implicit constant conversion [-Werror=overflow]
最后在nginx/obj/Makefile 中把 -Werror 选项去掉,则可以编译通过
参考文章:
https://blog.csdn.net/bbenben08/article/details/96964069
https://blog.csdn.net/fish43237/article/details/40515897
https://www.jianshu.com/p/5d9b60f7b262