交叉编译工具链: arm-poky-linux-gnueabi-gcc
./configure --prefix=/home/chad/Documents/nginx_cr --with-cc=arm-poky-linux-gnueabi-gcc
出现如下的问题
root@ubuntu:/home/chad/Downloads/nginx-1.18.0# ./configure --prefix=/home/chad/Documents/nginx_cr --with-cc=arm-poky-linux-gnueabi-gcc
checking for OS
+ Linux 4.15.0-101-generic x86_64
checking for C compiler ... not found
./configure: error: C compiler arm-poky-linux-gnueabi-gcc is not found
src/core/ngx_rwlock.c:125:2: error: #error ngx_atomic_cmp_set() is not defined!
#error ngx_atomic_cmp_set() is not defined!
^
objs/Makefile:547: recipe for target 'objs/src/core/ngx_rwlock.o' failed
make[1]: *** [objs/src/core/ngx_rwlock.o] Error 1
make[1]: Leaving directory '/home/chad/Downloads/nginx-1.18.0'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
解决办法,在configure的时候加上--without-http_upstream_zone_module
src/os/unix/ngx_errno.c: In function 'ngx_strerror':
src/os/unix/ngx_errno.c:37:31: error: 'NGX_SYS_NERR' undeclared (first use in this function)
msg = ((ngx_uint_t) err < NGX_SYS_NERR) ? &ngx_sys_errlist[err]:
^
src/os/unix/ngx_errno.c:37:31: note: each undeclared identifier is reported only once for each function it appears in
src/os/unix/ngx_errno.c: In function 'ngx_strerror_init':
src/os/unix/ngx_errno.c:58:11: error: 'NGX_SYS_NERR' undeclared (first use in this function)
len = NGX_SYS_NERR * sizeof(ngx_str_t);
^
objs/Makefile:664: recipe for target 'objs/src/os/unix/ngx_errno.o' failed
make[1]: *** [objs/src/os/unix/ngx_errno.o] Error 1
make[1]: Leaving directory '/home/chad/Downloads/nginx-1.18.0'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
出错的原因仍然是因为交叉编译程序无法本地运行,导致NGX_SYS_NERR宏没有赋值。解决办法,手动编辑 objs/ngx_auto_config.h,加上
#ifndef NGX_SYS_NERR
#define NGX_SYS_NERR 132
#endif