学习并整理windows下编译nginx的步骤
參考鏈接: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.batc) 在msys控制臺窗口中,運行配置腳本。(如需要粘貼命令,可以參考下面截圖方法粘貼)
這塊編譯某些openssl版本是會出錯,需要加上
--with-openssl-opt=no-asm2.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的步骤的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习LD_PRELOAD之摘抄
- 下一篇: java信息管理系统总结_java实现科