朱的工作记录  
技术博客
日历
<2016年2月>
31123456
78910111213
14151617181920
21222324252627
282912345
6789101112
统计
  • 随笔 - 2
  • 文章 - 4
  • 评论 - 4
  • 引用 - 0

导航

常用链接

留言簿(1)

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 
编译器: mipsel-linux-uclibc-gcc
环境:suse 9
软件:nginx-1.0.12和openssl-1.0.0g

使用gcc编译和顺利,直接使用./configure --without-pcre --with-http_ssl_module --with-openssl=/home/openssl-1.0.0g --without-http_rewrite_module
即可顺利make。在objs目录下就有生成的nginx程序。拷贝conf目录下的nginx.conf和html目录到objs下。修改nginx.conf配置。创建logs/errors.log文件。然后
./nginx -c nginx.conf
测试OK。

查了下,发现nginx本身不支持交叉编译。修改自己修改来支持。使用以下配置,发现出现很多错误。一个个改,看看能不能OK
./configure --without-pcre --with-http_ssl_module --with-openssl=/home/openssl-1.0.0g --without-http_rewrite_module --with-cc=/opt/mv_tools/bin/mipsel-linux-uclibc-gcc --with-cpp=/opt/mv_tools/bin/mipsel-linux-uclibc-g++ --with-ld-opt="-s -Wl,-rpath,::/mnt/:./" --without-http_gzip_module --crossbuild=cross-linux-32

因为nginx不支持交叉编译,只好把gcc替换成交叉编译器,修改auto/cc/gcc文件,尽量去掉和gcc有关的参数,只剩下
ngx_feature="gcc"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test=
. auto/feature

修改auto/feature文件,去掉:
ngx_feature="localtime_r()"
ngx_feature_name="NGX_HAVE_LOCALTIME_R"
ngx_feature_run=no

修改auto/types/sizeof文件,将ngx_size赋值为4,同时去掉
cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
#include <sys/time.h>
$NGX_INCLUDE_UNISTD_H
#include <signal.h>
#include <sys/resource.h>
$NGX_INCLUDE_INTTYPES_H
$NGX_INCLUDE_AUTO_CONFIG_H
int main() {
    printf("%d", sizeof($ngx_type));
    return 0;
}
END

修改auto/types/typedef文件,去掉 END下面的所以内容。

因为需要用到pre库,可以修改auto/lib/pre/make文件,在配置那行改成:
./configure --disable-shared --host=mipsel-linux-uclibc

用到openssl库,可以修改auto/lib/openssl/make文件,修改配置那行为:
&& ./Configure --prefix=$ngx_prefix no-shared linux-mipsel-ti:mipsel-linux-uclibc-gcc no-threads no-cast no-mdc2 no-rc2 no-rc5 no-krb5 \\
出现NGX_SYS_NERR未定义问题,试过其他办法都不行,最后只好在源文件ngx_error.c里面直接定义个值,
#define NGX_SYS_NERR 125//随便定义的,可能会有问题

出现ngx_shm_alloc未定义货找不到问题,使用mipsel-linux-uclibc-nm才知道函数没被编译进去,修改src/os/unix/ngx_shm.c,打开NGX_HAVE_MAP_ANON编译条件。

编译通过后,就可以在目标平台上运行了。测试了下,速度还行,感觉和Goahead差不多。试了下CGI,才发现nginx不能直接支持CGI。。查了下,可以支持fast-cgi,还是得通过其他模块来跑才可以,比如spawn-fcgi,可惜折腾过去,还是不行(spawn-fcgi一运行就没了,根本没在监听端口,搞不懂这个)。郁闷。暂时没时间继续搞这个。先记录下,待续。。
posted on 2012-02-15 12:45 阅读(5071) 评论(4)  编辑 收藏 引用 所属分类: Web Server
评论:
  • # re: nginx-1.0.12交叉编译[未登录]  kevin Posted @ 2013-01-11 19:52
    大哥哥,能私下聊吗,我也遇到这个问题,还没搞定,催的急,可不可以帮小弟一下啊。我请你吃饭,呵呵  回复  更多评论   

  • # re: nginx-1.0.12交叉编译[未登录]  kevin Posted @ 2013-01-11 19:54
    大哥哥,能私下聊吗,我也遇到这个问题,还没搞定,催的急,可不可以帮小弟一下啊。我请你吃饭,呵呵,我QQ:783358507  回复  更多评论   

  • # re: nginx-1.0.12交叉编译  kerner Posted @ 2013-01-15 11:38
    编译会有问题哦:如下:
    mipsel-linux-gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
    -o objs/src/event/ngx_event_accept.o \
    src/event/ngx_event_accept.c
    cc1: warnings being treated as errors
    src/event/ngx_event_accept.c: In function 'ngx_event_accept':
    src/event/ngx_event_accept.c:55:13: error: implicit declaration of function 'accept4'
    make[1]: *** [objs/src/event/ngx_event_accept.o] Error 1  回复  更多评论   

  • # re: nginx-1.0.12交叉编译  DOU.TR Posted @ 2016-02-16 17:26
    @kerner
    accept4 system call is available starting with Linux 2.6.28; support in glibc is available starting with version 2.10.   回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


 
Copyright © 朱 Powered by: 博客园 模板提供:沪江博客