win8.1下vs2013编译nginx

来源:互联网 发布:毒狗药三步倒淘宝 编辑:程序博客网 时间:2024/04/29 16:27

我的环境是win8.1 + vs2013社区版

1、安装msys。

http://sourceforge.net/projects/mingw/files/   Installer文件夹下有mingw-get,安装之后,弹出的界面中选择msys即可安装msys。

2、下载 zlib、openssl和pcre

下的几个版本为:openssl-1.0.1j、pcre-8.32、zlib-1.2.8

解压到 $(NGINX_SOURCE)\objs\lib 目录,这个$(NGINX_SOURCE)为nginx源码放置路径,例如D:\Tools\nginx。

3、生成makefile

a) 启动vs 2013命令行。  通过vs 2013工具命令行启动msys,能省略配置cl路径的步骤。

b) 在上述命令行中启动msys。

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC>cd /d C:\MinGW\msys\1.0C:\MinGW\msys\1.0>msys.bat
c) 在msys控制台窗口中,运行配置脚本

$ cd /d/Tools/nginx/$ 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.32 --with-zlib=objs/lib/zlib-1.2.8 --with-openssl=objs/lib/openssl-1.0.1j --with-select_module --with-http_ssl_module --with-ipv6

如果不想下载zlib(gzip模块需要)、pcre(rewrite模块需要)和openssl,可以修改一下configure命令行

$ 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-select_module --without-http_rewrite_module --without-http_gzip_module

为了更好的调试,可以修改--with-cc-opt选项,定义_DEBUG宏,并修改生成的makefile禁用优化。

// 编译时增加_DEBUG宏--with-cc-opt="-DFD_SETSIZE=1024 -D_DEBUG"
// 修改生成的objs\Makefile文件里CFLAGS标志。CFLAGS =  -Od -W4 -nologo -MT -Zi -DFD_SETSIZE=1024 -D_DEBUG -DNO_SYS_TYPES_H
4、启动编译。

在编译之前,需要修改一下makefile,去掉CFLAGS中的-WX编译选项,否则vs2013会把警告当错误终止编译。

cd D:\Tools\nginx\nmake -f objs\Makefile

5、运行nginx。

a) 把objs\nginx.exe拷贝到上一级目录。

b) 创建文件夹logs、temp

c) 启动nginx.exe


0 0
原创粉丝点击