從零開始 Nginx 交叉編譯

交叉編譯工具鏈: 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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章