在使用MinGW和nmake编译Nginx并添加心跳检测模块的过程中,可能会遇到一些常见的问题。以下是一些常见问题及其解决方案:
常见问题和解决方案
-
编译环境配置错误
-
问题:auto/configure: error: the ngx_http_upstream_check_module addon error.
-
解决方案:修改C:\nginx_build\nginx_upstream_check_module\config文件。
-
-
编译报错
-
问题:nmake过程中报错:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include “ngx_config.h””?。
-
解决方案:修改C:\nginx_build\nginx_upstream_check_module\ngx_http_upstream_check_module.c文件,新增头文件ngx_config.h:
#include "ngx_config.h"
-
-
编译报错
-
问题:warning C4200: 使用了非标准扩展: 结构/联合中的零大小数组。
-
解决方案:修改数组定义0角标为1,others[0]改为others[1]:
-
-
编译错误
-
问题: warning C4245: “return”: 从“int”转换到“ngx_uint_t”,有符号/无符 号不匹配。
-
解决方案:为变量加上(unsigned)修饰:
-
-
编译错误
- 问题: warning C4013: “srandom”未定义;假设外部返回 int。
- 解决方案:将srandom改为srand
-
链接错误
-
问题: warning C4702: 无法访问的代码。
-
解决方案:注释掉无法访问的代码
-