Windows下用MinGW32/MSYS32编译Squid时Make报错的解决咨询
在MinGW32/MSYS32环境编译Squid 3.4.14解决宏重定义错误的方案
问题复现
编译执行
make check或make install时触发如下错误:
In file included from ../compat/compat.h:76, from ../include/squid.h:66, from assert.cc:32: ../compat/os/mswindows.h:178: error: "S_IRWXO" redefined [-Werror] #define S_IRWXO 007 In file included from ../compat/os/mswindows.h:54, from ../compat/compat.h:76, from ../include/squid.h:66, from assert.cc:32: C:/Strawberry/c/i686-w64-mingw32/include/sys/stat.h:163: note: this is the location of the previous definition #define S_IRWXO (S_IRWXG >> 3) cc1plus.exe: all warnings being treated as errors make[1]: *** [Makefile:907: assert.lo] Error 1 make[1]: Leaving directory 'C:/msys32/home/paulg/squid-3.4.14/compat' make: *** [Makefile:572: check-recursive] Error 1
移除Makefile中的-Werror标志后,错误依然存在。
解决方案
这个问题的核心是Squid兼容性头文件与MinGW系统头文件的宏定义冲突,即使去掉-Werror,宏重复定义本身会被编译器判定为错误,而非警告。直接修改冲突的头文件即可解决:
- 打开Squid源码目录下的
compat/os/mswindows.h文件 - 定位到第178行附近的
#define S_IRWXO 007代码 - 将其替换为条件编译代码,避免重复定义:
#ifndef S_IRWXO #define S_IRWXO 007 #endif
- 保存文件后,重新执行
make check或make install
额外处理建议
- 如果后续遇到其他类似的宏重定义错误(比如
S_IRWXG、S_IRWXU等),可以用同样的方式给Squid自定义的宏加上#ifndef判断 - 确保你的MinGW32/MSYS32版本与Squid 3.4.14官方部署指南要求的版本匹配,版本不兼容也可能引发这类兼容性问题
内容的提问来源于stack exchange,提问作者chickencommander123
相关产品推荐
相关产品推荐

