尝试在Windows上编译Nginx时失败

时间:2019-10-23 11:00:07

标签: windows nginx compilation openssl mingw

使用nmake进行编译时,出现错误。

首先,我首先根据Vern的出色教程尝试使用msys:https://stackoverflow.com/a/22649559/5092846 然后,我尝试使用msys2执行具有相同结果的相同步骤

这些是我的配置参数(zlib,pcre,openssl和nginx-rtmp-module存在于正确的目录中):

auto/configure \
    --with-cc=cl \
    --with-debug \
    --prefix= \
    --conf-path=conf/nginx.conf \
    --pid-path=logs/nginx.pid \
    --http-log-path=logs/access.log \
    --error-log-path=logs/error.log \
    --sbin-path=nginx.exe \
    --http-client-body-temp-path=temp/client_body_temp \
    --http-proxy-temp-path=temp/proxy_temp \
    --http-fastcgi-temp-path=temp/fastcgi_temp \
    --http-scgi-temp-path=temp/scgi_temp \
    --http-uwsgi-temp-path=temp/uwsgi_temp \
    --with-cc-opt=-DFD_SETSIZE=1024 \
    --with-pcre=objs/lib/pcre-8.43 \
    --with-zlib=objs/lib/zlib-1.2.11 \
    --with-openssl=objs/lib/openssl-1.1.1c \
    --with-openssl-opt=no-asm \
    --with-http_ssl_module \
    --add-module=nginx-rtmp-module

运行nmake -f Makefile的结果是:

$ nmake -f Makefile

Microsoft (R) Program Maintenance Utility Version 14.23.28105.4
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" -f objs/Makefile

Microsoft (R) Program Maintenance Utility Version 14.23.28105.4
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" -f auto/lib/openssl/makefile.msvc                                 OPENSSL="objs/lib/openssl-1.1.1c" OPENSSL_OPT="no-asm"

Microsoft (R) Program Maintenance Utility Version 14.23.28105.4
Copyright (C) Microsoft Corporation.  All rights reserved.

        cd objs/lib/openssl-1.1.1c
        perl Configure VC-WIN32 no-shared                                --prefix="%cd%/openssl"                              --openssldir="%cd%/openssl/ssl"                          no-asm
Configuring OpenSSL version 1.1.1c (0x1010103fL) for VC-WIN32
Using os-specific seed configuration
Creating configdata.pm
Creating makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
        if exist ms\do_ms.bat (                                          ms\do_ms                                             && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" -f ms\nt.mak                                    && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" -f ms\nt.mak install                           ) else (                                     "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe"           && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" install_sw                                      )

Microsoft (R) Program Maintenance Utility Version 14.23.28105.4
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\perl32\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl"  "-omakefile" "crypto\include\internal\bn_conf.h.in" > crypto\include\internal\bn_conf.h
        "C:\perl32\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl"  "-omakefile" "crypto\include\internal\dso_conf.h.in" > crypto\include\internal\dso_conf.h
        "C:\perl32\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl"  "-omakefile" "include\openssl\opensslconf.h.in" > include\openssl\opensslconf.h
        "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" /                   depend && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe" /                   _all

Microsoft (R) Program Maintenance Utility Version 14.23.28105.4
Copyright (C) Microsoft Corporation.  All rights reserved.


Microsoft (R) Program Maintenance Utility Version 14.23.28105.4
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\perl32\Strawberry\perl\bin\perl.exe" "util\mkbuildinf.pl" "cl /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 /WX -D"L_ENDIAN" -D"OPENSSL_PIC"" "VC-WIN32" > crypto\buildinf.h
        cl  /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 /WX /I "." /I "crypto\include" /I "include" /I "crypto" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR=\"C:\\MinGW\\msys2\\nginx\\objs\\lib\\openssl-1.1.1c\\openssl\\ssl\"" -D"ENGINESDIR=\"C:\\MinGW\\msys2\\nginx\\objs\\lib\\openssl-1.1.1c\\openssl\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"NDEBUG"  -c /Focrypto\cversion.obj "crypto\cversion.c"
cversion.c
C:\MinGW\msys2\nginx\objs\lib\openssl-1.1.1c\include\internal/cryptlib.h(13): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'if' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\nmake.exe"' : return code '0x2'
Stop.

如果我正确理解这一点,则失败是在编译opensl时-在stdlib.h文件中(或缺少该文件)。

1 个答案:

答案 0 :(得分:0)

首先启动“ VS 2019开发者命令提示符”提示,然后从内部运行msys,从而解决了该问题。