我尝试用RTMP模块编译NGINX for Windows,但总是出错。我一直遵循的指南是http://nginx.org/en/docs/howto_build_on_win32.html
我安装了以下软件:
- 管理系统2
- 草莓Perl(64位)
- Visual Studio 2022(社区版)+使用C++工作负载进行桌面开发
安装MSYS 2后,我按照他们的安装后说明找到here
pacman -Syu
pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
我已经为PATH设置了以下系统环境变量集
C:\Strawberry\c\bin
C:\Strawberry\perl\site\bin
C:\Strawberry\perl\bin
C:\msys64\mingw64\bin
我已经将NGINX源代码下载到了'C:'驱动器上一个名为'nginx'的目录中。在这个目录中,我下载并解压缩了以下包到目录'objs/lib'中。
- zlib-1.2.11
- pcre2-10.39
- openssl-1.1.1m
- 模块-1.2.2
这将创建以下目录结构
nginx
objs
lib
zlib-1.2.11
pcre2-10.39
openssl-1.1.1m
nginx-rtmp-module-1.2.2
我已通过运行Visual C目录中'vcvarsall.bat'脚本设置了Visual C环境
PS C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build> .\vcvarsall.bat amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.0.5
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
在其他一些指南中,他们指示修改位于“auto\lib\openssl”的“makefile.msvc”文件原始文件
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
all:
cd $(OPENSSL)
perl Configure VC-WIN32 no-shared \
--prefix="%cd%/openssl" \
--openssldir="%cd%/openssl/ssl" \
$(OPENSSL_OPT)
if exist ms\do_ms.bat ( \
ms\do_ms \
&& $(MAKE) -f ms\nt.mak \
&& $(MAKE) -f ms\nt.mak install \
) else ( \
$(MAKE) \
&& $(MAKE) install_sw \
)
修改的文件
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
all:
cd $(OPENSSL)
perl Configure VC-WIN64A no-shared \
--prefix="%cd%/openssl" \
--openssldir="%cd%/openssl/ssl" \
$(OPENSSL_OPT)
if exist ms\do_win64a.bat ( \
ms\do_ms \
&& $(MAKE) -f ms\nt.mak \
&& $(MAKE) -f ms\nt.mak install \
) else ( \
$(MAKE) \
&& $(MAKE) install_sw \
)
我已使用MSYS 2 MinGW x64运行了配置脚本
auto/configure \
--with-cc=cl \
--with-debug \
--builddir=objs \
--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/pcre2-10.39 \
--with-zlib=objs/lib/zlib-1.2.11 \
--with-openssl=objs/lib/openssl-1.1.1m \
--with-openssl-opt=no-asm \
--with-http_ssl_module \
--add-module=objs/lib/nginx-rtmp-module-1.2.2 \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_v2_module \
--with-stream \
--with-stream_ssl_module \
--with-http_dav_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_stub_status_module
checking for OS
+ MINGW64_NT-10.0-19044 3.3.3-341.x86_64 x86_64
+ using Microsoft Visual C++ compiler
+ cl version: 19.30
checking for MINGW64_NT-10.0-19044 specific features
configuring additional modules
adding module in objs/lib/nginx-rtmp-module-1.2.2
+ ngx_rtmp_module was configured
creating objs/Makefile
Configuration summary
+ using PCRE2 library: objs/lib/pcre2-10.39
+ using OpenSSL library: objs/lib/openssl-1.1.1m
+ using zlib library: objs/lib/zlib-1.2.11
nginx path prefix: ""
nginx binary file: "/nginx.exe"
nginx modules path: "/modules"
nginx configuration prefix: "/conf"
nginx configuration file: "/conf/nginx.conf"
nginx pid file: "/logs/nginx.pid"
nginx error log file: "/logs/error.log"
nginx http access log file: "/logs/access.log"
nginx http client request body temporary files: "temp/client_body_temp"
nginx http proxy temporary files: "temp/proxy_temp"
nginx http fastcgi temporary files: "temp/fastcgi_temp"
nginx http uwsgi temporary files: "temp/uwsgi_temp"
nginx http scgi temporary files: "temp/scgi_temp"
最后,为了构建NGINX,我在“VS 2022的x64原生工具命令提示符”中运行了“nmake”命令,这给了我错误
C:\nginx>nmake
Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" -f objs/Makefile
Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" -f auto/lib/openssl/makefile.msvc OPENSSL="objs/lib/openssl-1.1.1m" OPENSSL_OPT="no-asm"
Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
cd objs/lib/openssl-1.1.1m
perl Configure VC-WIN64A no-shared --prefix="%cd%/openssl" --openssldir="%cd%/openssl/ssl" no-asm
Configuring OpenSSL version 1.1.1m (0x101010dfL) for VC-WIN64A
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_win64a.bat ( ms\do_ms
&& "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" -f ms\nt.mak && "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" -f ms\nt.mak install ) else (
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" && "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" install_sw )
Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl" "-omakefile" "include\crypto\bn_conf.h.in" > include\crypto\bn_conf.h
"C:\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl" "-omakefile" "include\crypto\dso_conf.h.in" > include\crypto\dso_conf.h
"C:\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl" "-omakefile" "include\openssl\opensslconf.h.in" > include\openssl\opensslconf.h
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" / depend && "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe" / _all
Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:\Strawberry\perl\bin\perl.exe" "util\mkbuildinf.pl" "cl /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 -D"L_ENDIAN" -D"OPENSSL_PIC"" "VC-WIN64A" > crypto\buildinf.h
cl /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 /I "." /I "include" /I "crypto" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR=\"C:\\nginx\\objs\\lib\\openssl-1.1.1m\\openssl\\ssl\"" -D"ENGINESDIR=\"C:\\nginx\\objs\\lib\\openssl-1.1.1m\\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
cl /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 /I "." /I "include" /I "crypto" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR=\"C:\\nginx\\objs\\lib\\openssl-1.1.1m\\openssl\\ssl\"" -D"ENGINESDIR=\"C:\\nginx\\objs\\lib\\openssl-1.1.1m\\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" /Zs /showIncludes "crypto\cversion.c" 2>&1 > crypto\cversion.d
lib /nologo /out:libcrypto.lib @C:\Users\Will\AppData\Local\Temp\nm8B87.tmp
crypto\cversion.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\lib.EXE"' : return code '0x458'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'if' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
我哪里做错了?
1条答案
按热度按时间oxiaedzo1#
我尝试做同样的事情。我设法让构建更沿着但仍然遇到了一个问题,即OpenSSL不是从NGINX Makefile构建的,但确实使用nmake单独为x64构建了OpenSSL。以下是我的步骤:
1.我从他们的Git仓库中查看了以下三个仓库:
2.更改到openssl文件夹,并按照基本文件夹中的www.example.com文件所述设置输出环境变量NOTES-WINDOWS.md:
3.运行perl配置命令
4.执行nmake
正在创建库应用程序\openssl.lib和对象应用程序\openssl.exp IF EXIST应用程序\openssl.exe。清单“mt”-nologo -清单应用程序\openssl.exe。清单-输出资源:应用程序\openssl.exe
5.创建目标文件夹并授予自己对它们的完全控制权限
6.将OpenSSL二进制文件和SSL公用库安装到目标文件夹中
(我将在稍后编辑此部分,以添加到目前为止NGINX构建的其余部分...)