在安装Nginx时,你可能会遇到以下错误:

make -f objs/Makefile
make[1]: Entering directory '/home/liu-jy/桌面/nginx-1.10.1'
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../pcre-8.40 -I ../zlib-1.2.11 -I objs \	-o objs/src/core/ngx_murmurhash.o \	src/core/ngx_murmurhash.c
src/core/ngx_murmurhash.c: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
   37 |         h ^= data[2] << 16;      |
   37 |         ~~^~~~~~~~~~~~~~~~src/core/ngx_murmurhash.c:38:5: note: here
   38 |     case 2:      |
   38 |     ^~~~src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
   39 |         h ^= data[1] << 8;      |
   39 |         ~~^~~~~~~~~~~~~~~src/core/ngx_murmurhash.c:40:5: note: here
   40 |     case 1:      |
   40 |     ^~~~cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:465: objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/home/liu-jy/桌面/nginx-1.10.1'
make: *** [Makefile:8: build] Error 2

这个错误是由于编译选项 -Werror 将所有警告视为错误,包括隐式的掉落(implicit-fallthrough)导致的。

解决方法:

  1. 修改 Makefile 文件:

    • 打开 Makefile 文件,找到 CFLAGS 变量。
    • -Werror 标志移除。
    • 保存文件并重新运行 make 命令。
  2. 使用 make 命令参数:

    • 在命令行中运行 make -k 命令。这将跳过错误并继续构建。

在 Linux 下的 Vim 编辑器中进行搜索:

  • 使用命令 /搜索内容 进行搜索。
  • 例如,要搜索文件中的 'hello world',可以在命令模式下输入:/hello world
  • 按下回车键后,Vim 会自动跳转到第一个匹配项的位置并将其高亮显示。
  • 要查找下一个匹配项,按下 n 键。
  • 要查找上一个匹配项,按下 Shift+n 键。
Nginx安装错误:make 错误  'this statement may fall through' 解决方法

原文地址: https://www.cveoy.top/t/topic/ovNz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录