title: Why am I getting errors compiling NGINX for Windows?
body: <p>I'm trying to compile NGINX with the RTMP module for Windows but I keep getting errors. The guide I've been following is <a href="http://nginx.org/en/docs/howto_build_on_win32.html" rel="nofollow noreferrer">http://nginx.org/en/docs/howto_build_on_win32.html</a></p>
  <p>I have the following software installed:</p>
  <ul>
  <li>MSYS2</li>
  <li>Strawberry Perl (64-bit)</li>
  <li>Visual Studio 2022 (community edition) + Desktop Development with C++ workload</li>
  </ul>
  <p>After installing MSYS2 I followed their post-installation instructions found <a href="https://www.msys2.org/" rel="nofollow noreferrer">here</a></p>
  <pre><code>pacman -Syu
  pacman -Su
  pacman -S --needed base-devel mingw-w64-x86_64-toolchain
  </code></pre>
  <p>I have set the following System environment variables set for PATH</p>
  <pre><code>C:\Strawberry\c\bin
  C:\Strawberry\perl\site\bin
  C:\Strawberry\perl\bin
  C:\msys64\mingw64\bin
  </code></pre>
  <p>I've downloaded the NGINX source code into a directory called 'nginx' on the 'C:' drive. Inside this directory I've then downloaded and extracted the following packages into the directories 'objs/lib'.</p>
  <ul>
  <li>zlib-1.2.11</li>
  <li>pcre2-10.39</li>
  <li>openssl-1.1.1m</li>
  <li>nginx-rtmp-module-1.2.2</li>
  </ul>
  <p>This creates the following directory structure</p>
  <pre><code>nginx
      objs
          lib
              zlib-1.2.11
              pcre2-10.39
              openssl-1.1.1m 
              nginx-rtmp-module-1.2.2
  </code></pre>
  <p>I have set Visual C environment by running 'vcvarsall.bat' script from Visual C directory</p>
  <pre><code>PS C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build&gt; .\vcvarsall.bat amd64
  **********************************************************************
  ** Visual Studio 2022 Developer Command Prompt v17.0.5
  ** Copyright (c) 2021 Microsoft Corporation
  **********************************************************************
  [vcvarsall.bat] Environment initialized for: 'x64'
  </code></pre>
  <p>In some other guides they instructed to modify the 'makefile.msvc' file found at 'auto\lib\openssl'
  <strong>Original file</strong></p>
  <pre><code># Copyright (C) Igor Sysoev
  # Copyright (C) Nginx, Inc.
  
  
  all:
      cd $(OPENSSL)
  
      perl Configure VC-WIN32 no-shared               \
          --prefix=&quot;%cd%/openssl&quot;                 \
          --openssldir=&quot;%cd%/openssl/ssl&quot;             \
          $(OPENSSL_OPT)
  
      if exist ms\do_ms.bat (                     \
          ms\do_ms                        \
          &amp;&amp; $(MAKE) -f ms\nt.mak                 \
          &amp;&amp; $(MAKE) -f ms\nt.mak install             \
      ) else (                            \
          $(MAKE)                         \
          &amp;&amp; $(MAKE) install_sw                   \
      )
  </code></pre>
  <p><strong>Modified file</strong></p>
  <pre><code># Copyright (C) Igor Sysoev
  # Copyright (C) Nginx, Inc.
  
  
  all:
      cd $(OPENSSL)
  
      perl Configure VC-WIN64A no-shared              \
          --prefix=&quot;%cd%/openssl&quot;                 \
          --openssldir=&quot;%cd%/openssl/ssl&quot;             \
          $(OPENSSL_OPT)
  
      if exist ms\do_win64a.bat (                     \
          ms\do_ms                        \
          &amp;&amp; $(MAKE) -f ms\nt.mak                 \
          &amp;&amp; $(MAKE) -f ms\nt.mak install             \
      ) else (                            \
          $(MAKE)                         \
          &amp;&amp; $(MAKE) install_sw                   \
      )
  </code></pre>
  <p>Using MSYS2 MinGW x64 I have ran the configure script</p>
  <pre><code>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: &quot;&quot;
    nginx binary file: &quot;/nginx.exe&quot;
    nginx modules path: &quot;/modules&quot;
    nginx configuration prefix: &quot;/conf&quot;
    nginx configuration file: &quot;/conf/nginx.conf&quot;
    nginx pid file: &quot;/logs/nginx.pid&quot;
    nginx error log file: &quot;/logs/error.log&quot;
    nginx http access log file: &quot;/logs/access.log&quot;
    nginx http client request body temporary files: &quot;temp/client_body_temp&quot;
    nginx http proxy temporary files: &quot;temp/proxy_temp&quot;
    nginx http fastcgi temporary files: &quot;temp/fastcgi_temp&quot;
    nginx http uwsgi temporary files: &quot;temp/uwsgi_temp&quot;
    nginx http scgi temporary files: &quot;temp/scgi_temp&quot;
  </code></pre>
  <p>Lastly to build NGINX I ran the 'nmake' command in 'x64 Native Tools Command Prompt for VS 2022' which gives me the errors</p>
  <pre><code>C:\nginx&gt;nmake
  
  Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
          &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; -f objs/Makefile
  
  Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
          &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; -f auto/lib/openssl/makefile.msvc                                 OPENSSL=&quot;objs/lib/openssl-1.1.1m&quot; OPENSSL_OPT=&quot;no-asm&quot;
  
  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=&quot;%cd%/openssl&quot;                                 --openssldir=&quot;%cd%/openssl/ssl&quot;                         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 &lt;https://github.com/openssl/openssl/issues&gt;  ***
  ***   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
           &amp;&amp; &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; -f ms\nt.mak                                   &amp;&amp; &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; -f ms\nt.mak install                           ) else (
                           &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot;                                                   &amp;&amp; &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; install_sw                                     )
  
  Microsoft (R) Program Maintenance Utility Version 14.30.30709.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
          &quot;C:\Strawberry\perl\bin\perl.exe&quot; &quot;-I.&quot; -Mconfigdata &quot;util\dofile.pl&quot;  &quot;-omakefile&quot; &quot;include\crypto\bn_conf.h.in&quot; &gt; include\crypto\bn_conf.h
          &quot;C:\Strawberry\perl\bin\perl.exe&quot; &quot;-I.&quot; -Mconfigdata &quot;util\dofile.pl&quot;  &quot;-omakefile&quot; &quot;include\crypto\dso_conf.h.in&quot; &gt; include\crypto\dso_conf.h
          &quot;C:\Strawberry\perl\bin\perl.exe&quot; &quot;-I.&quot; -Mconfigdata &quot;util\dofile.pl&quot;  &quot;-omakefile&quot; &quot;include\openssl\opensslconf.h.in&quot; &gt; include\openssl\opensslconf.h
          &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; /                   depend &amp;&amp; &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot; /                   _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.
  
          &quot;C:\Strawberry\perl\bin\perl.exe&quot; &quot;util\mkbuildinf.pl&quot; &quot;cl /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 -D&quot;L_ENDIAN&quot; -D&quot;OPENSSL_PIC&quot;&quot; &quot;VC-WIN64A&quot; &gt; crypto\buildinf.h
          cl  /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 /I &quot;.&quot; /I &quot;include&quot; /I &quot;crypto&quot; -D&quot;L_ENDIAN&quot; -D&quot;OPENSSL_PIC&quot; -D&quot;OPENSSLDIR=\&quot;C:\\nginx\\objs\\lib\\openssl-1.1.1m\\openssl\\ssl\&quot;&quot; -D&quot;ENGINESDIR=\&quot;C:\\nginx\\objs\\lib\\openssl-1.1.1m\\openssl\\lib\\engines-1_1\&quot;&quot; -D&quot;OPENSSL_SYS_WIN32&quot; -D&quot;WIN32_LEAN_AND_MEAN&quot; -D&quot;UNICODE&quot; -D&quot;_UNICODE&quot; -D&quot;_CRT_SECURE_NO_DEPRECATE&quot; -D&quot;_WINSOCK_DEPRECATED_NO_WARNINGS&quot; -D&quot;NDEBUG&quot;  -c /Focrypto\cversion.obj &quot;crypto\cversion.c&quot;
  cversion.c
          cl  /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy /W3 /wd4090 /nologo /O2 /I &quot;.&quot; /I &quot;include&quot; /I &quot;crypto&quot; -D&quot;L_ENDIAN&quot; -D&quot;OPENSSL_PIC&quot; -D&quot;OPENSSLDIR=\&quot;C:\\nginx\\objs\\lib\\openssl-1.1.1m\\openssl\\ssl\&quot;&quot; -D&quot;ENGINESDIR=\&quot;C:\\nginx\\objs\\lib\\openssl-1.1.1m\\openssl\\lib\\engines-1_1\&quot;&quot; -D&quot;OPENSSL_SYS_WIN32&quot; -D&quot;WIN32_LEAN_AND_MEAN&quot; -D&quot;UNICODE&quot; -D&quot;_UNICODE&quot; -D&quot;_CRT_SECURE_NO_DEPRECATE&quot; -D&quot;_WINSOCK_DEPRECATED_NO_WARNINGS&quot; -D&quot;NDEBUG&quot;  /Zs /showIncludes &quot;crypto\cversion.c&quot; 2&gt;&amp;1 &gt; 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: '&quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\lib.EXE&quot;' : return code '0x458'
  Stop.
  NMAKE : fatal error U1077: '&quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot;' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077: 'if' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077: '&quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot;' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077: '&quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\nmake.exe&quot;' : return code '0x2'
  Stop.
  </code></pre>
  <p>Where am I going wrong?</p>