arm移植:nginx

编译如下:
cd /home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/nginx-1.20.2 && ./configure --prefix=/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/install-nginx-1.20.2 --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --without-http_upstream_zone_module --with-openssl=/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/../../openSource/openssl/openssl-1.1.1k/ --with-zlib=/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/../../openSource/zlib/zlib-1.2.11/ --with-pcre=/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/../../openSource/pcre/pcre-8.44/ --with-cc=arm-himix200-linux-gcc \
    && make && make install

问题参考:https://blog.csdn.net/vc66vcc/article/details/83273252
1.
./configure: error: C compiler arm-himix200-linux-gcc is not found
修改:nginx-1.20.2/auto/cc/name
ngx_feature_run=yes
改为
ngx_feature_run=no

2.
checking for int size ...auto/types/sizeof: line 43: objs/autotest: cannot execute binary file: Exec format error
修改:nginx-1.20.2/auto/type/sizeof
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
          -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
//改为
ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS \
          -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
          
3.
checking whether we are cross compiling... configure: error: in `/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/openSource/pcre/pcre-8.44':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
修改:nginx-1.20.2/auto/lib/pcre/make
./configure --disable-shared $PCRE_CONF_OPT
//改为
./configure --host=arm-himix200-linux --disable-shared $PCRE_CONF_OPT

4.
由于openssl默认用gcc编译,需要修改:nginx-1.20.2/auto/lib/openssl/make
&& ./config --prefix=$ngx_prefix no-shared no-threads $OPENSSL_OPT \\
改为:
&& ./Configure --prefix=$ngx_prefix no-shared no-threads linux-generic32 no-asm --cross-compile-prefix=arm-himix200-linux- $OPENSSL_OPT \\
备注:OPENSSL_OPT可以通过--with-openssl-opt="linux-generic32 no-asm --cross-compile-prefix=$(CROSS_COMPILE)-"来配置
&& ./Configure --prefix=$ngx_prefix no-shared no-threads $OPENSSL_OPT \\

5错误.
In file included from src/core/ngx_string.c:8:0:
src/core/ngx_string.c: In function 'ngx_atoi':
src/core/ngx_config.h:92:30: error: overflow in implicit constant conversion [-Werror=overflow]
 #define NGX_MAX_INT_T_VALUE  9223372036854775807
                              ^
src/core/ngx_string.c:975:14: note: in expansion of macro 'NGX_MAX_INT_T_VALUE'
     cutoff = NGX_MAX_INT_T_VALUE / 10;


是因为第2条修改用的是gcc来测试void*空间大小,我电脑是64位的,而arm是32位的。导致程序NGX_PTR_SIZE位8,导致编译出错
修改:nginx-1.20.2/auto/type/sizeof
int main(void) {
    printf("%d", (int) sizeof($ngx_type));//改为printf("%d", 4);
    return 0;
}

END


ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ //改为ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS \
          -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"

eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"

6.
src/core/ngx_rwlock.c:125:2: error: #error ngx_atomic_cmp_set() is not defined!
解决办法,在configure的时候加上--without-http_upstream_zone_module,来取消宏NGX_HTTP_UPSTREAM_ZONE

7.
/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/nginx-1.20.2/src/core/ngx_cycle.c:485: undefined reference to `ngx_shm_alloc'
/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/nginx-1.20.2/src/core/ngx_cycle.c:695: undefined reference to `ngx_shm_free'
/home/lxin/workdir/lxsvn/embedsvndir/surpassdir/lzdoorMngHost/common/fixedSrc/nginx/nginx-1.20.2/src/core/ngx_cycle.c:912: undefined reference to `ngx_shm_free'
因为宏NGX_HAVE_SYSVSHM没有生效
修改:nginx-1.20.2/auto/unix
ngx_feature="System V shared memory"
ngx_feature_name="NGX_HAVE_SYSVSHM"
ngx_feature_run=yes // 改为ngx_feature_run=no
ngx_feature_incs="#include <sys/ipc.h>
                  #include <sys/shm.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int  id;
                  id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
                  if (id == -1) return 0;
                  shmctl(id, IPC_RMID, NULL);"
. auto/feature

8运行时:
/mnt/nfs/acstmpdir/install-nginx-1.20.2/sbin # ./nginx -c //mnt/nfs/acstmpdir/install-nginx-1.20.2/conf/nginx.conf -e /mnt/record/nginxerr/error.log&
/mnt/nfs/acstmpdir/install-nginx-1.20.2/sbin # nginx: [alert] could not open error log file: open() "/mnt/record/nginxerr/error.log" failed (2: No such file or directory)
解决:把nginx整个安装目录都拷贝到板子上去,然后把这个目录使用-p连接即可:虽然-e可以解决error log报错,但是还是存在其他问题!
./nginx -c //mnt/nfs/acstmpdir/install-nginx-1.20.2/conf/nginx.conf -p /mnt/nfs/acstmpdir/install-nginx-1.20.2/&


9运行时出现:
/mnt/nfs/acstmpdir/install-nginx-1.20.2/sbin # ./nginx -c //mnt/nfs/acstmpdir/install-nginx-1.20.2/conf/nginx.conf -e /mnt/record/error.log&
/mnt/nfs/acstmpdir/install-nginx-1.20.2/sbin # nginx: [emerg] getpwnam("nobody") failed
打开conf/nginx.conf文件,修改#user  nobody;为user  root;即可

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值