checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ...auto/types/sizeof: line 43: objs/autotest: cannot execute binary file
bytes
/home/gwwu/codes/istanbul_5_28/app/nginx/nginx-1.8.0/configure: error: can not detect int size
cat: objs/autotest.c: No such file or directory
make: *** [header] Error 1
错误原因:
原因也是由于nginx里面判断某个特征是否具备是通过编译在auto/type/sizeof里面的一段c代码并且运行编译结果,由于交叉编译的环境是powerpc-linux-gnu-gcc,但是在编译的linux主机上,无法运行powerpc-linux-gnu-gcc编译的目标文件,所以导致提示 objs/autotest: cannot execute binary file,并最终退出。
修改方法:
修改文件nginx-1.8.0/auto/type/sizeof, 15行修改为4,注册掉17到33行
14
15 ngx_size= -------------15行修改为4,注册掉17到33行
16
17 cat << END > $NGX_AUTOTEST.c
18
19 #include <sys/types.h>
20 #include <sys/time.h>
21 $NGX_INCLUDE_UNISTD_H
22 #include <signal.h>
23 #include <stdio.h>
24 #include <sys/resource.h>
25 $NGX_INCLUDE_INTTYPES_H
26 $NGX_INCLUDE_AUTO_CONFIG_H
27
28 int main() {
29 printf("%d", (int) sizeof($ngx_type));
30 return 0;
31 }
32
33 END
3)继续编译,出现如下错误:
checking for OpenSSL library ... not found
/home/gwwu/codes/istanbul_5_28/app/nginx/nginx-1.8.0/configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
make: *** [header] Error 1
错误原因:
由于在nginx-1.8.0/auto/lib/openssl/conf的65行里面有个判断$OPENSSL != YES,由于没有指定--with-openssl=<path>,所以会导致退出。
autoest.c
#include <sys/types.h>
#include <unistd.h>
#include <openssl/ssl.h>
int main() {
SSL_library_init();
return 0;
}
powerpc-linux-gnu-gcc -I/home/gwwu/codes/istanbul_5_28/build_BR200/app/openssl/openssl/include -I/home/gwwu/codes/istanbul_5_28/include/share -I/home/gwwu/codes/istanbul_5_28/include/user -I/home/gwwu/codes/istanbul_5_28/include/boot -I/home/gwwu/codes/istanbul_5_28/build_BR200/include/boot -I/home/gwwu/codes/istanbul_5_28/build_BR200/include/share -I/home/gwwu/codes/istanbul_5_28/build_BR200/include/user -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -o objs/autotest objs/autotest.c -lssl -lcrypto
编译失败,由于没有编译主机上没有这两个库文件
解决方法:
如果环境中没有openssl库的,需要用--with-openssl选项指定。
但在我们的环境中,是有openssl库的,所以不需要指定--with-openssl,但是为了解决这个退出错误,注释掉56行,增加57 行ngx_found=yes
45 if [ "$NGX_PLATFORM" != win32 ]; then
46
47 OPENSSL=NO
48
49 ngx_feature="OpenSSL library"
50 ngx_feature_name="NGX_OPENSSL"
51 ngx_feature_run=no
52 ngx_feature_incs="#include <openssl/ssl.h>"
53 ngx_feature_path=
54 ngx_feature_libs="-lssl -lcrypto"
55 ngx_feature_test="SSL_library_init()"
56 . auto/feature ----------注释掉此行
57 增加ngx_found=yes
58 if [ $ngx_found = yes ]; then
59 have=NGX_SSL . auto/have
60 CORE_LIBS="$CORE_LIBS $ngx_feature_libs $NGX_LIBDL"
61 OPENSSL=YES
62 fi
63 fi
4)继续编译,出现错误:
make[2]: Entering directory `/home/gwwu/codes/istanbul_5_28/build_BR200/app/nginx/nginx-1.8.0'
cd ../pcre2-10.10 \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="powerpc-linux-gnu-gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... powerpc-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/home/gwwu/codes/istanbul_5_28/build_BR200/app/nginx/pcre2-10.10':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
make[2]: *** [../pcre2-10.10/Makefile] Error 1
make[2]: Leaving directory `/home/gwwu/codes/istanbul_5_28/build_BR200/app/nginx/nginx-1.8.0'
make[1]: *** [build] Error 2
make[1]: Leaving directory `/home/gwwu/codes/istanbul_5_28/build_BR200/app/nginx/nginx-1.8.0'
make: *** [header] Error 2
错误原因:
pcre交叉编译的时候必须指定--host
修改:
nginx/nginx-1.8.0/auto/lib/pcre/make里面56行,增加--host=x86_64-unknown-linux-gnu
51
52 $PCRE/Makefile: $NGX_MAKEFILE
53 cd $PCRE \\
54 && if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
55 && CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
56 ./configure --host=linux_x86_64 --disable-shared $PCRE_CONF_OPT --------增加--host=x86_64-unknown-linux-gnu
57
58 $PCRE/.libs/libpcre.a: $PCRE/Makefile
59 cd $PCRE \\
60 && \$(MAKE) libpcre.la
61
62 END