参考链接:https://blog.csdn.net/i348018533/article/details/51701865

https://blog.csdn.net/hyhnoproblem/article/details/42365393

一、安装msys

点击左侧All Packages->msys->MSYS Base System检查右侧菜单的选中组件中是否有msys-make、msys-tar,没有选中则选中安装即可。

二、下载源码

2.1 下载nginx源码和依赖模块

2.2 下载zlib、openssl和pcre

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

2.3生成makefile

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

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

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC>cd /d C:\MinGW\msys\1.0  C:\MinGW\msys\1.0>msys.bat 

c) 在msys控制台窗口中,运行配置脚本。(如需要粘贴命令,可以参考下面截图方法粘贴)

这块编译某些openssl版本是会出错,需要加上

--with-openssl-opt=no-asm

2.4 编译

还是在刚才vs 2015的命令行窗口中输入:

编译过程中,会遇到一些问题,可以搜索谷歌来解决,谷歌上面没有答案的话,自己尝试来解决。下面列出一些问题:

(1) 编译过程中,需要perl工具,我刚开始下载草莓perl下不下来,然后连上vpn之后就可以下载安装了。

(2) 如果出现如下错误:

error LNK2019: 无法解析的外部符号 _OPENSSL_ia32_cpuid,该符号在函数 _OPENSSL_cpuid_setup 中被引用
原因是之前编译的临时文件没有清理的问题,因为我之前编译的时候没有添加no-asm选项,后面加上时没有清理就直接编译了,那肯定有问题。所以重新清理下再编译即可。
nmake -f ms\nt.mak clean

(3)出现如下错误,这块将-WX去掉了

(4). 编译pcre的时候,需要以下修改:

第一步:把config.h.generic重命名成config.h.

第二步:把pcre.h.generic重命名成pcre.h。

第三步:重命名pcre_chartables.c.dist为pcre_chartables.c。

2.5 运行nginx

注意:在运行之前,还需要把所需要的动态库放到nginx\nginx-xxx\目录中,如libapr-1.dll、libapriconv-1.dll、libaprutil-1.dll、pcre3.dll

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

b)创建文件夹logs、temp

c)启动nginx.exe

注意:在增加了add-module iwall3模块之后,编译需要去掉预编译头:

编译动态库的时候,需要去掉如下注释:

然后修改auto/make,如下图所示是需要增加的内容:

然后就可以使用nmake -f build/Makefile来编译动态库了(add-dynamic-module)

修改的auto/make和auto/cc/msvc文件如下:


# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.echo "creating $NGX_MAKEFILE"mkdir -p $NGX_OBJS/src/core $NGX_OBJS/src/event $NGX_OBJS/src/event/modules \$NGX_OBJS/src/os/unix $NGX_OBJS/src/os/win32 \$NGX_OBJS/src/http $NGX_OBJS/src/http/v2 $NGX_OBJS/src/http/modules \$NGX_OBJS/src/http/modules/perl \$NGX_OBJS/src/mail \$NGX_OBJS/src/stream \$NGX_OBJS/src/miscngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`cat << END                                                     > $NGX_MAKEFILECC =    $CC
CFLAGS = $CFLAGS
CPP =  $CPP
LINK = $LINKENDif test -n "$NGX_PERL_CFLAGS"; thenecho NGX_PERL_CFLAGS = $NGX_PERL_CFLAGS                   >> $NGX_MAKEFILEecho NGX_PM_CFLAGS = $NGX_PM_CFLAGS                       >> $NGX_MAKEFILEecho NGX_PM_LDFLAGS = $NGX_PM_LDFLAGS                     >> $NGX_MAKEFILE
fi# ALL_INCS, required by the addons and by OpenWatcom C precompiled headersngx_incs=`echo $CORE_INCS $NGX_OBJS $HTTP_INCS $MAIL_INCS $STREAM_INCS\| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \-e "s/\//$ngx_regex_dirsep/g"`cat << END                                                    >> $NGX_MAKEFILEALL_INCS = $ngx_include_opt$ngx_incsENDngx_all_srcs="$CORE_SRCS"# the core dependencies and include pathsngx_deps=`echo $CORE_DEPS $NGX_AUTO_CONFIG_H $NGX_PCH \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_incs=`echo $CORE_INCS $NGX_OBJS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \-e "s/\//$ngx_regex_dirsep/g"`cat << END                                                    >> $NGX_MAKEFILECORE_DEPS = $ngx_depsCORE_INCS = $ngx_include_opt$ngx_incsEND# the http dependencies and include pathsif [ $HTTP = YES ]; thenngx_all_srcs="$ngx_all_srcs $HTTP_SRCS"ngx_deps=`echo $HTTP_DEPS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_incs=`echo $HTTP_INCS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \-e "s/\//$ngx_regex_dirsep/g"`cat << END                                                >> $NGX_MAKEFILEHTTP_DEPS = $ngx_depsHTTP_INCS = $ngx_include_opt$ngx_incsENDfi# the mail dependencies and include pathsif [ $MAIL != NO ]; thenif [ $MAIL = YES ]; thenngx_all_srcs="$ngx_all_srcs $MAIL_SRCS"fingx_deps=`echo $MAIL_DEPS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_incs=`echo $MAIL_INCS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \-e "s/\//$ngx_regex_dirsep/g"`cat << END                                                >> $NGX_MAKEFILEMAIL_DEPS = $ngx_depsMAIL_INCS = $ngx_include_opt$ngx_incsENDfi# the stream dependencies and include pathsif [ $STREAM != NO ]; thenif [ $STREAM = YES ]; thenngx_all_srcs="$ngx_all_srcs $STREAM_SRCS"fingx_deps=`echo $STREAM_DEPS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_incs=`echo $STREAM_INCS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \-e "s/\//$ngx_regex_dirsep/g"`cat << END                                                >> $NGX_MAKEFILESTREAM_DEPS = $ngx_depsSTREAM_INCS = $ngx_include_opt$ngx_incsENDfingx_all_srcs="$ngx_all_srcs $MISC_SRCS"if test -n "$NGX_ADDON_SRCS$DYNAMIC_MODULES"; thencat << END                                                >> $NGX_MAKEFILEADDON_DEPS = \$(CORE_DEPS) $NGX_ADDON_DEPSENDfi# nginxngx_all_srcs=`echo $ngx_all_srcs | sed -e "s/\//$ngx_regex_dirsep/g"`for ngx_src in $NGX_ADDON_SRCS
dongx_obj="addon/`basename \`dirname $ngx_src\``"test -d $NGX_OBJS/$ngx_obj || mkdir -p $NGX_OBJS/$ngx_objngx_obj=`echo $ngx_obj/\`basename $ngx_src\` \| sed -e "s/\//$ngx_regex_dirsep/g"`ngx_all_srcs="$ngx_all_srcs $ngx_obj"
donengx_all_objs=`echo $ngx_all_srcs \| sed -e "s#\([^ ]*\.\)cpp#$NGX_OBJS\/\1$ngx_objext#g" \-e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \-e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g" \-e "s#\([^ ]*\.\)S#$NGX_OBJS\/\1$ngx_objext#g"`ngx_modules_c=`echo $NGX_MODULES_C | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_modules_obj=`echo $ngx_modules_c | sed -e "s/\(.*\.\)c/\1$ngx_objext/"`if test -n "$NGX_RES"; thenngx_res=$NGX_RES
elsengx_res="$NGX_RC $NGX_ICONS"ngx_rcc=`echo $NGX_RCC | sed -e "s/\//$ngx_regex_dirsep/g"`
fingx_deps=`echo $ngx_all_objs $ngx_modules_obj $ngx_res $LINK_DEPS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_libs=
if test -n "$NGX_LD_OPT$CORE_LIBS"; thenngx_libs=`echo $NGX_LD_OPT $CORE_LIBS \| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`
fingx_link=${CORE_LINK:+`echo $CORE_LINK \| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}ngx_main_link=${MAIN_LINK:+`echo $MAIN_LINK \| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}#\$(LINK) $ngx_long_start$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main_linkcat << END                                                    >> $NGX_MAKEFILEbuild:   binary nginx_lib modules manpage binary:    $NGX_OBJS${ngx_dirsep}nginx$ngx_binext$NGX_OBJS${ngx_dirsep}nginx$ngx_binext:   $ngx_deps$ngx_spacer\$(LINK) $ngx_long_start$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main$ngx_rcc
$ngx_long_endnginx_lib: $NGX_OBJS${ngx_dirsep}nginx.lib$NGX_OBJS${ngx_dirsep}nginx.lib: $ngx_deps$ngx_spacerlib $ngx_long_start $ngx_objs /out:$NGX_OBJS${ngx_dirsep}nginx.lib
$ngx_long_end    modules:
END# ngx_modules.cif test -n "$NGX_PCH"; thenngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
elsengx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS)"
ficat << END                                                    >> $NGX_MAKEFILE$ngx_modules_obj:   \$(CORE_DEPS)$ngx_cont$ngx_modules_c$ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c$NGX_AUXEND# the core sourcesfor ngx_src in $CORE_SRCS
dongx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_obj=`echo $ngx_src \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`cat << END                                                >> $NGX_MAKEFILE$ngx_obj:    \$(CORE_DEPS)$ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDdone# the http sourcesif [ $HTTP = YES ]; thenif test -n "$NGX_PCH"; thenngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"elsengx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"ngx_perl_cc="\$(CC) $ngx_compile_opt \$(NGX_PERL_CFLAGS)"ngx_perl_cc="$ngx_perl_cc \$(CORE_INCS) \$(HTTP_INCS)"fifor ngx_source in $HTTP_SRCSdongx_src=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_obj=`echo $ngx_src \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`if [ $ngx_source = src/http/modules/perl/ngx_http_perl_module.c ]; thencat << END                                        >> $NGX_MAKEFILE$ngx_obj: \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src$ngx_perl_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDelsecat << END                                        >> $NGX_MAKEFILE$ngx_obj:   \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDfidonefi# the mail sourcesif [ $MAIL = YES ]; thenif test -n "$NGX_PCH"; thenngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"elsengx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(MAIL_INCS)"fifor ngx_src in $MAIL_SRCSdongx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_obj=`echo $ngx_src \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`cat << END                                            >> $NGX_MAKEFILE$ngx_obj:  \$(CORE_DEPS) \$(MAIL_DEPS)$ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDdonefi# the stream sourcesif [ $STREAM = YES ]; thenif test -n "$NGX_PCH"; thenngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"elsengx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(STREAM_INCS)"fifor ngx_src in $STREAM_SRCSdongx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_obj=`echo $ngx_src \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`cat << END                                            >> $NGX_MAKEFILE$ngx_obj:    \$(CORE_DEPS) \$(STREAM_DEPS)$ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDdonefi# the misc sourcesif test -n "$MISC_SRCS"; thenngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"for ngx_src in $MISC_SRCSdongx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_obj=`echo $ngx_src \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`cat << END                                            >> $NGX_MAKEFILE$ngx_obj: \$(CORE_DEPS) $ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDdonefi# the addons sourcesif test -n "$NGX_ADDON_SRCS"; thenngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"for ngx_src in $NGX_ADDON_SRCSdongx_obj="addon/`basename \`dirname $ngx_src\``"ngx_obj=`echo $ngx_obj/\`basename $ngx_src\` \| sed -e "s/\//$ngx_regex_dirsep/g"`ngx_obj=`echo $ngx_obj \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`cat << END                                            >> $NGX_MAKEFILE$ngx_obj: \$(ADDON_DEPS)$ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDdonefi# the addons config.makeif test -n "$NGX_ADDONS$DYNAMIC_ADDONS"; thenfor ngx_addon_dir in $NGX_ADDONS $DYNAMIC_ADDONSdoif test -f $ngx_addon_dir/config.make; then. $ngx_addon_dir/config.makefidone
fi# Win32 resource fileif test -n "$NGX_RES"; thenngx_res=`echo "$NGX_RES: $NGX_RC $NGX_ICONS" \| sed -e "s/\//$ngx_regex_dirsep/g"`ngx_rcc=`echo $NGX_RCC | sed -e "s/\//$ngx_regex_dirsep/g"`cat << END                                                >> $NGX_MAKEFILE$ngx_res$ngx_rccENDfi# the precompiled headersif test -n "$NGX_PCH"; thenecho "#include <ngx_config.h>" > $NGX_OBJS/ngx_pch.cngx_pch="src/core/ngx_config.h $OS_CONFIG $NGX_OBJS/ngx_auto_config.h"ngx_pch=`echo "$NGX_PCH:   $ngx_pch" | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_src="\$(CC) \$(CFLAGS) $NGX_BUILD_PCH $ngx_compile_opt \$(ALL_INCS)"ngx_src="$ngx_src $ngx_objout$NGX_OBJS/ngx_pch.obj $NGX_OBJS/ngx_pch.c"ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`cat << END                                                >> $NGX_MAKEFILE$ngx_pch$ngx_srcENDfi# dynamic modulesif test -n "$NGX_PCH"; thenngx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
elsengx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) \$(ALL_INCS)"ngx_perl_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(NGX_PERL_CFLAGS)"ngx_perl_cc="$ngx_perl_cc \$(ALL_INCS)"
fifor ngx_module in $DYNAMIC_MODULES
doeval ngx_module_srcs="\$${ngx_module}_SRCS"eval eval ngx_module_libs="\\\"\$${ngx_module}_LIBS\\\""eval ngx_module_modules="\$${ngx_module}_MODULES"eval ngx_module_order="\$${ngx_module}_ORDER"ngx_modules_c=$NGX_OBJS/${ngx_module}_modules.ccat << END                                    > $ngx_modules_c#include <ngx_config.h>
#include <ngx_core.h>ENDfor mod in $ngx_module_modulesdoecho "extern ngx_module_t  $mod;"         >> $ngx_modules_cdoneecho                                          >> $ngx_modules_cecho 'extern ngx_module_t *ngx_modules[] = {'        >> $ngx_modules_cfor mod in $ngx_module_modulesdoecho "    &$mod,"                         >> $ngx_modules_cdonecat << END                                    >> $ngx_modules_cNULL
};
ENDecho 'extern char *ngx_module_names[] = {'           >> $ngx_modules_cfor mod in $ngx_module_modulesdoecho "    \"$mod\","                      >> $ngx_modules_cdonecat << END                                    >> $ngx_modules_cNULL
};ENDecho 'extern char *ngx_module_order[] = {'           >> $ngx_modules_cfor mod in $ngx_module_orderdoecho "    \"$mod\","                      >> $ngx_modules_cdonecat << END                                    >> $ngx_modules_cNULL
};ENDngx_modules_c=`echo $ngx_modules_c | sed -e "s/\//$ngx_regex_dirsep/g"`ngx_modules_obj=`echo $ngx_modules_c \| sed -e "s/\(.*\.\)c/\1$ngx_objext/"`ngx_module_objs=for ngx_src in $ngx_module_srcsdocase "$ngx_src" insrc/*)ngx_obj=$ngx_src;;*)ngx_obj="addon/`basename \`dirname $ngx_src\``"mkdir -p $NGX_OBJS/$ngx_objngx_obj="$ngx_obj/`basename $ngx_src`";;esacngx_module_objs="$ngx_module_objs $ngx_obj"donengx_module_objs=`echo $ngx_module_objs \| sed -e "s#\([^ ]*\.\)cpp#$NGX_OBJS\/\1$ngx_objext#g" \-e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \-e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g" \-e "s#\([^ ]*\.\)S#$NGX_OBJS\/\1$ngx_objext#g"`ngx_deps=`echo $ngx_module_objs $ngx_modules_obj $LINK_DEPS \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_objs=`echo $ngx_module_objs $ngx_modules_obj \| sed -e "s/  *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \-e "s/\//$ngx_regex_dirsep/g"`ngx_obj=$NGX_OBJS$ngx_dirsep$ngx_module$ngx_modextif [ "$NGX_PLATFORM" = win32 ]; thenngx_module_libs="$CORE_LIBS $ngx_module_libs"fingx_libs=if test -n "$NGX_LD_OPT$ngx_module_libs"; thenngx_libs=`echo $NGX_LD_OPT $ngx_module_libs \| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`fingx_link=${CORE_LINK:+`echo $CORE_LINK \| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}ngx_module_link=${MODULE_LINK:+`echo $MODULE_LINK \| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}cat << END                                            >> $NGX_MAKEFILEmodules:  $ngx_obj$ngx_obj:   $ngx_deps$ngx_spacer\$(LINK) $ngx_long_start$ngx_binout$ngx_obj$ngx_long_cont$ngx_objs$ngx_module_link$ngx_libs$ngx_link$ngx_main_link
$ngx_long_end$ngx_modules_obj:  \$(CORE_DEPS)$ngx_cont$ngx_modules_c$ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c$NGX_AUXENDfor ngx_source in $ngx_module_srcsdocase "$ngx_source" insrc/*)ngx_obj=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`;;*)ngx_obj="addon/`basename \`dirname $ngx_source\``"ngx_obj=`echo $ngx_obj/\`basename $ngx_source\` \| sed -e "s/\//$ngx_regex_dirsep/g"`;;esacngx_obj=`echo $ngx_obj \| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`ngx_src=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`if [ $ngx_source = src/http/modules/perl/ngx_http_perl_module.c ]; thencat << END                                        >> $NGX_MAKEFILE$ngx_obj: \$(ADDON_DEPS)$ngx_cont$ngx_src$ngx_perl_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDelsecat << END                                        >> $NGX_MAKEFILE$ngx_obj:    \$(ADDON_DEPS)$ngx_cont$ngx_src$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUXENDfidone
donecat << END                                                    > $NGX_OBJS/nginx.def
LIBRARYEXPORTSngx_modulesngx_module_namesngx_module_orderEND

# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.# MSVC 6.0 SP2                            cl 12.00
# MSVC Toolkit 2003 (7.1)                 cl 13.10
# MSVC 2005 Express Edition SP1 (8.0)     cl 14.00
# MSVC 2008 Express Edition (9.0)         cl 15.00
# MSVC 2010 (10.0)                        cl 16.00
# MSVC 2015 (14.0)                        cl 19.00NGX_MSVC_VER=`$NGX_WINE $CC 2>&1 | grep 'Compiler Version' 2>&1 \| sed -e 's/^.* Version \(.*\)/\1/'`
NGX_MSVC_VER=19
echo " + cl version: $NGX_MSVC_VER"have=NGX_COMPILER value="\"cl $NGX_MSVC_VER\"" . auto/definengx_msvc_ver=`echo $NGX_MSVC_VER | sed -e 's/^\([0-9]*\).*/\1/'`# optimizations# maximize speed, equivalent to -Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy
CFLAGS="$CFLAGS -O2"# enable global optimization
#CFLAGS="$CFLAGS -Og"
# enable intrinsic functions
#CFLAGS="$CFLAGS -Oi"# disable inline expansion
#CFLAGS="$CFLAGS -Ob0"
# explicit inline expansion
#CFLAGS="$CFLAGS -Ob1"
# explicit and implicit inline expansion
#CFLAGS="$CFLAGS -Ob2"# enable frame pointer omission
#CFLAGS="$CFLAGS -Oy"
# disable stack checking calls
#CFLAGS="$CFLAGS -Gs"# pools strings as read/write
#CFLAGS="$CFLAGS -Gf"
# pools strings as read-only
#CFLAGS="$CFLAGS -GF"case $CPU inpentium)# optimize for Pentium and AthlonCPU_OPT="-G5";;pentiumpro)# optimize for Pentium Pro, Pentium II and Pentium IIICPU_OPT="-G6";;pentium4)# optimize for Pentium 4, MSVC 7CPU_OPT="-G7";;
esac# __cdecl, default, must be used with OpenSSL, md5 asm, and sha1 asm
#CPU_OPT="$CPU_OPT -Gd"
# __stdcall
#CPU_OPT="$CPU_OPT -Gz"
# __fastcall
#CPU_OPT="$CPU_OPT -Gr"CFLAGS="$CFLAGS $CPU_OPT"# warningsCFLAGS="$CFLAGS -W4"# stop on warning
CFLAGS="$CFLAGS -WX"# disable logo
CFLAGS="$CFLAGS -nologo"# the link flags
CORE_LINK="$CORE_LINK -link -verbose:lib"# link with libcmt.lib, multithreaded
LIBC="-MT"
# link with msvcrt.dll
# however, MSVC Toolkit 2003 has no MSVCRT.LIB
#LIBC="-MD"CFLAGS="$CFLAGS $LIBC"CORE_LIBS="$CORE_LIBS kernel32.lib user32.lib"# Win32 GUI mode application
#CORE_LINK="$CORE_LINK -subsystem:windows -entry:mainCRTStartup"# debug
# msvc under Wine issues
# C1902: Program database manager mismatch; please check your installation
if [ -z "$NGX_WINE" ]; thenCFLAGS="$CFLAGS -Zi"CORE_LINK="$CORE_LINK -debug"
fi# MSVC 2005 supports C99 variadic macros
if [ "$ngx_msvc_ver" -ge 14 ]; thenhave=NGX_HAVE_C99_VARIADIC_MACROS . auto/have
fi# precompiled headers
#CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
#CORE_LINK="$CORE_LINK $NGX_OBJS/ngx_pch.obj"
#NGX_PCH="$NGX_OBJS/ngx_config.pch"
#NGX_BUILD_PCH="-Ycngx_config.h -Fp$NGX_OBJS/ngx_config.pch"
#NGX_USE_PCH="-Yungx_config.h -Fp$NGX_OBJS/ngx_config.pch"# the resource file
NGX_RES="$NGX_OBJS/nginx.res"
NGX_RCC="rc -fo$NGX_RES \$(CORE_INCS) $NGX_WIN32_RC"
CORE_LINK="$NGX_RES $CORE_LINK"# dynamic modules
MAIN_LINK="-link -def:$NGX_OBJS/nginx.def"
MODULE_LINK="-LD $NGX_OBJS/nginx.lib"ngx_pic_opt=
ngx_objout="-Fo"
ngx_binout="-Fe"
ngx_objext="obj"
ngx_binext=".exe"ngx_long_start='@<<'
ngx_long_end='<<'
ngx_long_regex_cont=' \'
ngx_long_cont=''# MSVC understand / in path
#ngx_regex_dirsep='\\'
#ngx_dirsep="\\"

运行动态库的过程(load_module)出现了错误,目前还没解决。

学习并整理windows下编译nginx的步骤相关推荐

  1. linux下软件编译终止,[2018年最新整理]linux下编译运行程序命令大全.ppt

    [2018年最新整理]linux下编译运行程序命令大全 1. 项目课题引入 2. Vi编辑器的使用方法 3. Linux中C语言程序的编辑 4. Linux中C语言程序的运行 5. 现场演示案例 课题 ...

  2. 记一次失败的Windows环境编译Nginx源码

    最近想学习下nginx的源码,之前在linux环境编译安装过多次,在windows环境还是第一次尝试,遇到了不少问题,记录一下.可惜的是编译成功后,在最后运行的时候还是会报错,如果有人遇到类似的问题希 ...

  3. Windows下编译Chrome V8

    主要还是参考google的官方文档: How to Download and Build V8 Building on Windows 同时也参考了一些其它的中文博客: 脚本引擎小pk:SpiderM ...

  4. Windows下编译TensorFlow1.3 C++ library及创建一个简单的TensorFlow C++程序

    参考:https://www.cnblogs.com/jliangqiu2016/p/7642471.html Windows下编译TensorFlow1.3 C++ library及创建一个简单的T ...

  5. 在Windows下编译FFmpeg详细说明

    在Windows下编译FFmpeg详细说明 MinGW:一个可自由使用和自由发布的Windows特定头文件和使用GNC工具集导入库的集合,允许你生成本地的Windows程序而不需要第三方C运行时 Mi ...

  6. fastdfs windows部署_Go在windows下编译Linux可执行文件

    欢迎关注我的头条号:Wooola,专注于Java.Golang.微服务架构,致力于每天分享原创文章.快乐编码和开源技术. 前言 最近楼主做了一个滑块验证码登录功能,但有个问题,悲观估计一天大约会产生两 ...

  7. Windows下编译扩展OpenCV 3.1.0 + opencv_contrib

    在Windows下编译扩展OpenCV 3.1.0 + opencv_contrib 为什么要CMake,这里我陈述自己的想法,作为一个刚使用opencv库的小白来说,有以下大概三点内容 1.由于在学 ...

  8. caffe学习日记--lesson4:windows下caffe DEMO (mnist and cifar10)

    caffe学习日记--lesson4:windows下caffe DEMO (mnist and cifar10) 1.下载数据 mnist官网:http://yann.lecun.com/exdb/ ...

  9. 记录 Windows 下编译一个开源 SM9 签名验签 C 程序的过程

    注:本文不讨论算法具体实现细节,只介绍如何编译一个现有的程序实现. 在商用密码检测中心( 链接:http://www.scctc.org.cn/index.aspx )的网站上,"下载中心& ...

最新文章

  1. 20亿参数,大型视觉Transformer来了,刷新ImageNet Top1,All you need is money!
  2. 在Git存储库中查找并恢复已删除的文件
  3. fdisk命令非交互模式及parted的mkpart命令第一个参数说明
  4. 计算机视觉算法实战书籍推荐_岗位内推 | 字节跳动招聘NLP、计算机视觉、推荐算法实习生...
  5. 电文的编码和译码c语言实现,电文的编码及译码.doc
  6. 法流程图_世界五大学习方法之西蒙学习法
  7. 基于优化反馈的组合在线学习
  8. 王思聪限制消费令被取消!
  9. (0)C#开发环境构建——史上最容易理解的C#界面搭建
  10. IIS7.5应用程序池集成模式和经典模式的区别介绍
  11. ni数据采集卡C语言API接口,NI数据采集卡
  12. 【matlab】Simulink 微分模块的线性化问题
  13. 《改变心理学的40项研究》第二章 知觉与意识
  14. 菱形是一种特殊的平行四边形,是四条边均相等的平行四边形。题目给出菱形的边长n,用*画出菱形。如n=1,输出:
  15. linux系统修改屏幕分辨率6,Linux系统怎么更改屏幕分辨率
  16. 如何在图数据库上实现图计算框架
  17. pythontuple数据类型_阿博的Python之路-详解Tuple数据类型
  18. python dataframe去掉索引_python中pandas.DataFrame的简单操作方法(创建、索引、增添与删除)...
  19. 基于flask的在线笔记共享管理系统【2】(数据库的设计和建立)
  20. 结构光逆相机法重建详解+代码

热门文章

  1. mmap 内存映射详解
  2. C++学习笔记:(二)函数重载 常量与引用
  3. hdu 4497 GCD and LCM
  4. 简便解法:1004 成绩排名 (20分)
  5. 被忽略的知识点——switch语句
  6. Mysql可重复读实现原理分析
  7. 如何统一集体的所有人的yum环境(以阿里云为例)
  8. 上个ensp实验只发了配置,这次是命令条目
  9. abap 函数远程启用的模块参数_SAP AMDP介绍 - ABAP托管的HANA数据库过程
  10. oracle数据库开多线程,学习笔记:Oracle表数据导入 DBA常用单线程插入 多线程插入 sql loader三种表数据导入案例...