首页 > 代码库 > nginx-1.5.10 之mips编译到RT5350

nginx-1.5.10 之mips编译到RT5350

编译nginx-1.5.10一般需要以下库的支持:pcre,zlib,openssl

此次编译nginx-1.5.10使用的库版本分别为pcre-8.34;openssl-1.0.0l;zlib-1.2.8将这些看和nginx放在同一目录如下图


在nginx添加一个shell脚本文件runscript.sh

#!/bin/sh
BUILD_PATH=../release
CC_PATH=/opt/buildroot-gcc342/bin/mipsel-linux-gcc 
CPP_PATH=/opt/buildroot-gcc342/bin/mipsel-linux-g++
./configure \
--with-openssl=/home/nginx/nginx/openssl-1.0.0l \
--prefix=$BUILD_PATH \
--user=nginx \
--group=nginx \
--builddir=$BUILD_PATH/build \
--with-zlib=/home/nginx/nginx/zlib-1.2.8 \
--with-pcre \
--with-pcre=/home/nginx/nginx/pcre-8.34 \
--with-pcre-jit \
--with-cc=$CC_PATH \
--with-cpp=$CPP_PATH \


执行脚本文件后成成makefile

src/os/unix/ngx_files.c: In function `ngx_read_ahead‘:
src/os/unix/ngx_files.c:473: warning: implicit declaration of function `posix_fadvise‘
make[1]: *** [../release/build/src/os/unix/ngx_files.o] 错误 1
make[1]: Leaving directory `/home/nginx/nginx/nginx-1.5.10‘
make: *** [build] 错误 2
[root@zq nginx-1.5.10]# 

将makefile中的

-Werror -g  去除

再次重新执行make,又出现错误
objs/src/core/ngx_cycle.o:In function `ngx_init_cycle‘:
/home/loongsoner/job/web-server/nginx-1.4.3/src/core/ngx_cycle.c:464:undefined reference to `ngx_shm_free‘
/home/loongsoner/job/web-server/nginx-1.4.3/src/core/ngx_cycle.c:469:undefined reference to `ngx_shm_alloc‘
/home/loongsoner/job/web-server/nginx-1.4.3/src/core/ngx_cycle.c:647:undefined reference to `ngx_shm_free‘
objs/src/event/ngx_event.o:In function `ngx_event_module_init‘:
/home/loongsoner/job/web-server/nginx-1.4.3/src/event/ngx_event.c:526:undefined reference to `ngx_shm_alloc‘
意思是ngx_shm_free和ngx_shm_alloc函数未定义,解决方法是定义宏NGX_HAVE_SYSVSHM 

在自动生成的头文件中添加以下宏

#ifndef NGX_SYS_NERR
#define NGX_SYS_NERR 132
#endif


#ifndef NGX_HAVE_SYSVSHM
#define NGX_HAVE_SYSVSHM1
#endif 


最终make && make install生成nginx