nginx交叉编译

nginx源码没有使用automake、autoconf、libtools这一套标准生成Makefile文件工具,而是自己写了一套脚本,位于源码auto目录下,使用auto/configure生成Makefile

在目标平台机器上编译是没有问题的,但交叉编译时因为无法执行目标平台的可执行程序,导致configure报错。

错误记录如下:
1、

checking for C compiler ... found but is not working
auto/configure: error: C compiler aarch64-linux-gnu-gcc is not found

修改auto/cc/name

 ngx_feature_run=yes
 =>
 ngx_feature_run=no

2、

auto/configure: error: can not detect int size

修改auto/types/sizeof

ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS ...
将其中的$CC用本机gcc替换

3、pcre、zlib、openssl

auto/configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
auto/configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
auto/configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

下载pcre源码

官网:https://www.pcre.org/
https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz

下载zlib源码

git clone https://github.com/madler/zlib.git

下载openssl源码

wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz

修改auto/lib/pcre/make

./configure --disable-shared $PCRE_CONF_OPT 
=>
./configure --disable-shared --host=linux-aarch64

修改auto/lib/opessl/make

./config --prefix=$ngx_prefix no-shared no-threads $OPENSSL_OPT
./Configure --prefix=$ngx_prefix no-shared no-threads no-asm
export CC=aarch64-linux-gnu-gcc
auto/configure --with-http_ssl_module --with-http_v2_module --with-pcre=../pcre-8.43 --with-zlib=../zlib --with-openssl=../openssl-1.1.1c
make
ithewei CSDN认证博客专家 c/c++ Qt libhv
编程之路,其路漫漫,吾将上下而求索
https://github.com/ithewei
https://hewei.blog.csdn.net
©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页