nginx 交叉编译 ( checking for C compiler found but is not wo

(如果有帮助,请点个赞;如果有错误,,请指出;如果转载,请注明出处)

注意:

由于博客编辑器兼容性的原因,本文中的代码空格和标点符号可能与实际情况存在差异。

所以在设置参数的时候,请手动输入;如果碰到错误,请检查configue –help和 gcc 里面的参数名字到底怎么写。

参考:《参考文章》

关键词:

(1)nginx 、 nginx-1.6.2(3)mips、openwrt(2)cross compile 、交叉编译(5)openssl 、pcre 、zlib(8)sha1 library is not found(9)SSL modules require the OpenSSL library.(10)make没有什么可以做的为`default’。(11)没有规则可以创建nginx.o需要的目标nginx.h(12)checking for C compiler … found but is not working

(13)autotest not found

(14)ELF ld-uClibc.so.0not found

(15)can not detect int size

(16)autotest.c: No such file or directory

(18)If you meant to cross compile, use `–host’.

See config.log for more details

(19)ngx_errno.c:In function ‘ngx_strerror’

ngx_errno.c:In function ‘ngx_strerror_init’:

(20)error: ‘NGX_SYS_NERR’ undeclared (first use in this function)

(21)Relocations in generic ELF (EM: 3)

(22)libssl.a:could not read symbols: File in wrong format

(23)x86cpuid.s

正文:

一般来说,编译 nginx 不会有太大的问题。但是因为 nginx 对交叉编译的支持不太好。所以如果想 nginx 移植到其它环境中,会出现比较多的问题。网上也能找到几篇关于 nginx 的交叉编译的文章,但是都是针对旧一点的版本。本文 编译的是最新的 stalble 版本,nginx-1.6.2

1、环境设置、声明变量、执行configure

(1)openwrt 环境变量

STAGING_DIR=/home/ubuntu/workplace/sdk/toolchain:$STAGING_DIR

export STAGING_DIR;

(2)export PATH=$PATH:/home/ubuntu/workplace/sdk/toolchain/bin

(3)nginx 编译用到的变量

BUILD_PATH=$PWD

INSTALL_PATH=$PWD/install

CC_PATH=/home/ubuntu/workplace/sdk/toolchain/bin/mips-openwrt-linux-uclibc-gcc

CPP_PATH=/home/ubuntu/workplace/sdk/toolchain/bin/mips-openwrt-linux-uclibc-g++

CONFIG_DIR=/app/nginx

LOG_DIR=/app/nginx/log

TEMP_DIR=/app/nginx/tmp

(4)执行configure,生成Makefile(由于博客编辑器的问题,下面的标点符号可能有误,直接复制粘贴会出报错)

./configure \

–prefix=$INSTALL_PATH\

–builddir=$BUILD_PATH/build \

–conf-path=$CONFIG_DIR/nginx.conf \

–error-log-path=$LOG_DIR/error.log \

–pid-path=$CONFIG_DIR/nginx.pid \

–lock-path=$CONFIG_DIR/nginx.lock \

–http-log-path=$LOG_DIR/access.log \

–http-client-body-temp-path=$TEMP_DIR/body \

–http-proxy-temp-path=$TEMP_DIR/proxy \

–http-fastcgi-temp-path=$TEMP_DIR/fastcgi \

–without-http_uwsgi_module \

–without-http_scgi_module \

–without-http_gzip_module \

–with-http_ssl_module \

–with-pcre=/home/ubuntu/packets/pcre-6.7 \

–with-openssl=/home/ubuntu/packets/openssl-1.0.1i \

–with-cc=$CC_PATH \

–with-cpp=$CPP_PATH \

–with-cc-opt="-I /home/ubuntu/workplace/sdk/toolchain/include" \

–with-ld-opt="-L /home/ubuntu/workplace/sdk/toolchain/lib"

(4)执行make 和make install

二、遇到的问题

(1)问题内容:

checking for C compiler … found but is not working

./configure error : C compiler gcc is not found

(2)原因分析:

configure首先会编译一个小测试程序,通过测试其运行结果来判断编译器是否能正常工作,由于交叉编译器所编译出的程序是无法在编译主机上运行的,故而产生此错误。

(3)解决办法:

编辑auto/cc/name文件,将21行的“exit 1”注释掉(令测试程序不会报错)。

三、遇到的问题

(1)问题内容:

autotest : 4 : not found

autotest:Syntax error: Unterminated quoted stringbytes

./configure : error:can not detect int size

cat : /home/ubuntu/packets/nginx-1.6.2/build/autotest.c: No such file or directory

(2)原因分析:

便是不再存在着任何我曾经对你有过的希望。

nginx 交叉编译 ( checking for C compiler found but is not wo

相关文章:

你感兴趣的文章:

标签云: