Compile NGINX with Visual Studio

I have 2 questions regarding NGINX:

  • Is there anyone who has already compiled NGINX with Visual Studio? I want to create a VS9 project to compile NGINX.

  • This is my real need, is there a way to compile NGINX as a Lib or DLL?

+4
source share
1 answer

I just finished a Visual Studio 2010 project for nginx. The process was not entirely direct, so I will try to tell in detail about everything that I learned. This is from a few hours to several days, depending on your experience.

1: nginx . nginx, .c .h, Visual Studio. . ( . .)

Unix, , . , Visual Studio.

I: nginx Windows MSYS

, . MSYS, Strawberry Perl, Mercurial PCRE, zlib OpenSSL. :

1) "". Visual Studio vc\vcvarsall.bat, VC . , , , :

"C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"

, Strawberry Perl 3 ( , PATH), Perl.

2) MSys, msys.bat. MSys MinGW, : C:\MinGW\MSYS\1,0\msys.bat

- : JensenV @AVWMA047LB ~ ( @networkaddress) , MINGW32: ~

, . msys\1.0\home. : C:\MinGW\MSYS\1.0\\JensenV

"ls" "dir", , .

3) , Mercurial, , ngynx: hg clone http://hg.nginx.org/nginx

, .

4) , perl - perl, , msys. : perl

- "/bin/perl.exe", perl, . ( , ) perl, msys. perl.exe perl_UNUSED.exe msys:

C:\MinGW\MSYS\1.0\Bin

, , " perl" Strawberry Perl, .

5) "link.exe" msys\1.0\bin: C:\MinGW\MSYS\1,0\Bin . (.. "link_UNUSED.exe" )

, , 1 "vcvarsall.bat" , / Microsoft C, 2 Msys. Microsoft.

, "link_UNUSED.exe" , : , Visual Studio 10, link.exe, msys.

6) "cd nginx" objs/lib nginx. Untar/unzip pcre, zlib openssl , guide.

7) nginx, nginx autoconfigure script, , sopenssl, pcre zlib, , objs/lib ( ). , , :

auto/configure --with-cc=cl --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 \
--with-cc-opt=-DFD_SETSIZE=1024 \
--with-pcre=objs/lib/pcre-8.33 \
--with-zlib=objs/lib/zlib-1.2.8 \
--with-openssl=objs/lib/openssl-1.0.1f \
--with-select_module --with-http_ssl_module --with-ipv6

, . .c .h, Visual Studio, , , , , .

7) .

nmake -f objs/Makefile

nginx.exe home\YourUsername\nginx\objs. - : C:\MinGW\MSYS\1.0\\JensenV\Nginx\OBJS

, , nginx.exe: ngx_auto_config.h ngx_auto_headers.h ngx_modules.c ngx_pch.c

Visual Studio.

8) .

**

II: nginx Visual Studio

**

Visual Studio . nginx ( ). : nginx msys , .

1) "" → " V++" Include:

$(MSBuildProjectDirectory)\SRC\ $ (MSBuildProjectDirectory)\SRC\ $ (MSBuildProjectDirectory)\SRC\\ $ (MSBuildProjectDirectory)\SRC\HTTP $ (MSBuildProjectDirectory)\SRC\HTTP\ $ (MSBuildProjectDirectory)\SRC\HTTP\\Perl $ (MSBuildProjectDirectory)\SRC\ $ (MSBuildProjectDirectory)\SRC\ $ (MSBuildProjectDirectory)\SRC\MySQL $ (MSBuildProjectDirectory)\SRC\ $ (MSBuildProjectDirectory)\OBJS $ (MSBuildProjectDirectory)\SRC\OS\win32 $ (MSBuildProjectDirectory)\OBJS\Lib\OpenSSL\SSL\ $ (MSBuildProjectDirectory)\OBJS\Lib\Zlib $ (MSBuildProjectDirectory)\OBJS\Lib\PCRE

. objs/lib zlib, pcre ssl. , . , , .

" → " , MSBuildProjectDirectory - nginx.

2) :

$(MSBuildProjectDirectory)\OBJS\Lib\OpenSSL\SSL\Lib \ $ (MSBuildProjectDirectory)\OBJS\Lib\PCRE \ $ (MSBuildProjectDirectory)\OBJS\Lib\Zlib\

, , , objs/lib .

3) :

/C++ : " " "" (WX-) : :   WIN32   NGX_WIN32   NGX_MAIL_SSL   NO_SYS_TYPES_H   FD_SETSIZE = 1024

Linker:  : : ws2_32.lib pcre.lib ssleay32.lib libeay32.lib crypt32.lib zlib.lib

4) Visual Studio. ( .vcxproj) , Notepad ++. ( , - .) nginx\objs\makefile .

make , , , - :

objs/nginx.exe: objs/src/core/nginx.obj \   objs/src/core/ngx_log.obj \   objs/src/core/ngx_palloc.obj \   objs/src/core/ngx_array.obj \       ....   objs/ngx_modules.obj \   objs/nginx.res \   objs/lib/pcre-8.33/pcre.lib \   OBJS/Library/Zlib-1.2.8/zlib.lib   $ (LINK) @< <

, Visual Studio, - ( , , , ), - :

        

, .obj makefile. " " , , Visual Studio ( .c/" > .obj\

. zlib.lib pcre.lib. , nginx.res. (, .)

, , Visual Studio . makefile , .

5) .c .h , nginx exe? . :

ngx_modules.c ngx_pch.c

6) !

, , - , , !

. , options nginx, auto/configure , nmake, Visual Studio ngx_modules.c ngx_pch.c Visual Studio.

+13

Source: https://habr.com/ru/post/1524749/


All Articles