安装fastfds中的nginx执行make命令报错-src/core/ngx_murmurhash.c:37:11: error

在尝试编译nginx时,遇到了-Werror=implicit-fallthrough警告导致的编译错误。该错误源于源代码中可能存在的未明确标记的switch-case转换。为了解决这个问题,可以修改Makefile文件,取消-Werror选项,防止警告被当作错误处理。同时,可以考虑注释掉引发警告的代码行,例如ngx_user.c中的特定语句。通过这些修改,可以成功编译nginx源代码。

问题

在nginx文件夹里执行make命令报错

src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[2] << 16;
         ~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
     case 2:
     ^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[1] << 8;
         ~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
     case 1:
     ^~~~

解决

修改Makefile文件,将Werror字样去掉

[root@localhost fastdfs]# vim ./nginx-1.8.0/objs/Makefile
CC =    cc
CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused Werror -g  -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='"/etc/fdfs/mod_fastdfs.conf"'

修改ngx_user.c文件,将cd.current_salt[0] = ~salt[0]注释掉

    /* work around the glibc bug */
   /* cd.current_salt[0] = ~salt[0]; */
root@iZbp1dkxm82gcg8ym1ce25Z:~/nginx-1.10.2# make make -f objs/Makefile make[1]: Entering directory '/root/nginx-1.10.2' 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 objs \ -o objs/src/core/nginx.o \ src/core/nginx.c 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 objs \ -o objs/src/core/ngx_log.o \ src/core/ngx_log.c 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 objs \ -o objs/src/core/ngx_palloc.o \ src/core/ngx_palloc.c 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 objs \ -o objs/src/core/ngx_array.o \ src/core/ngx_array.c 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 objs \ -o objs/src/core/ngx_list.o \ src/core/ngx_list.c 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 objs \ -o objs/src/core/ngx_hash.o \ src/core/ngx_hash.c 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 objs \ -o objs/src/core/ngx_buf.o \ src/core/ngx_buf.c 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 objs \ -o objs/src/core/ngx_queue.o \ src/core/ngx_queue.c 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 objs \ -o objs/src/core/ngx_output_chain.o \ src/core/ngx_output_chain.c 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 objs \ -o objs/src/core/ngx_string.o \ src/core/ngx_string.c 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 objs \ -o objs/src/core/ngx_parse.o \ src/core/ngx_parse.c 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 objs \ -o objs/src/core/ngx_parse_time.o \ src/core/ngx_parse_time.c 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 objs \ -o objs/src/core/ngx_inet.o \ src/core/ngx_inet.c 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 objs \ -o objs/src/core/ngx_file.o \ src/core/ngx_file.c 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 objs \ -o objs/src/core/ngx_crc32.o \ src/core/ngx_crc32.c 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 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; | ~~^~~~~~~~~~~~~~~~ src/core/ngx_murmurhash.c:38:5: note: here 38 | case 2: | ^~~~ src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=] 39 | h ^= data[1] << 8; | ~~^~~~~~~~~~~~~~~ src/core/ngx_murmurhash.c:40:5: note: here 40 | case 1: | ^~~~ cc1: all warnings being treated as errors make[1]: *** [objs/Makefile:458: objs/src/core/ngx_murmurhash.o] Error 1 make[1]: Leaving directory '/root/nginx-1.10.2' make: *** [Makefile:8: build] Error 2 root@iZbp1dkxm82gcg8ym1ce25Z:~/nginx-1.10.2# make install make -f objs/Makefile install make[1]: Entering directory '/root/nginx-1.10.2' 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 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; | ~~^~~~~~~~~~~~~~~~ src/core/ngx_murmurhash.c:38:5: note: here 38 | case 2: | ^~~~ src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=] 39 | h ^= data[1] << 8; | ~~^~~~~~~~~~~~~~~ src/core/ngx_murmurhash.c:40:5: note: here 40 | case 1: | ^~~~ cc1: all warnings being treated as errors make[1]: *** [objs/Makefile:458: objs/src/core/ngx_murmurhash.o] Error 1 make[1]: Leaving directory '/root/nginx-1.10.2' make: *** [Makefile:11: install] Error 2 root@iZbp1dkxm82gcg8ym1ce25Z:~/nginx-1.10.2# /usr/local/nginx/sbin/nginx -bash: /usr/local/nginx/sbin/nginx: No such file or directory root@iZbp1dkxm82gcg8ym1ce25Z:~/nginx-1.10.2# 你看 报错了。
最新发布
12-15
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I ../modules/nginx-client-module -I ../modules/nginx-multiport-module -I ../modules/nginx-toolkit-module -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../modules/nginx-rtmp-module -I objs -I src/http -I src/http/modules -I ../modules/nginx-rtmp-module -I ../modules/nginx-rtmp-module/http -I ../modules/nginx-rtmp-module/hls -I ../modules/nginx-rtmp-module/mpegts \ -o objs/src/http/ngx_http_parse.o \ src/http/ngx_http_parse.c cc1: all warnings being treated as errors make[1]: *** [objs/Makefile:995: objs/src/event/ngx_event_openssl.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory '/home/ubuntu/pingos-master/nginx' make: *** [Makefile:8: build] Error 2 make -f objs/Makefile install make[1]: Entering directory '/home/ubuntu/pingos-master/nginx' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I ../modules/nginx-client-module -I ../modules/nginx-multiport-module -I ../modules/nginx-toolkit-module -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../modules/nginx-rtmp-module -I objs \ -o objs/src/event/ngx_event_openssl.o \ src/event/ngx_event_openssl.c src/event/ngx_event_openssl.c: In function ‘ngx_ssl_load_certificate_key’: src/event/ngx_event_openssl.c:722:9: error: ‘ENGINE_by_id’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 722 | engine = ENGINE_by_id((char *) p); | ^~~~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:336:31: note: declared here 336 | OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_by_id(const char *id); | ^~~~~~~~~~~~ src/event/ngx_event_openssl.c:731:9: error: ‘ENGINE_load_private_key’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 731 | pkey = ENGINE_load_private_key(engine, (char *) last, 0, 0); | ^~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:638:11: note: declared here 638 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, | ^~~~~~~~~~~~~~~~~~~~~~~ src/event/ngx_event_openssl.c:735:13: error: ‘ENGINE_free’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 735 | ENGINE_free(engine); | ^~~~~~~~~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:493:27: note: declared here 493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); | ^~~~~~~~~~~ src/event/ngx_event_openssl.c:739:9: error: ‘ENGINE_free’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 739 | ENGINE_free(engine); | ^~~~~~~~~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:493:27: note: declared here 493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); | ^~~~~~~~~~~ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_dhparam’: src/event/ngx_event_openssl.c:1335:5: error: ‘PEM_read_bio_DHparams’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 1335 | dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); | ^~ In file included from /usr/include/openssl/ssl.h:36, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/pem.h:469:1: note: declared here 469 | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH) | ^~~~~~~~~~~~~~~~~~~ src/event/ngx_event_openssl.c:1345:5: error: ‘DH_free’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 1345 | DH_free(dh); | ^~~~~~~ In file included from /usr/include/openssl/dsa.h:51, from /usr/include/openssl/x509.h:37, from /usr/include/openssl/ssl.h:31, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/dh.h:204:28: note: declared here 204 | OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh); | ^~~~~~~ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_error: src/event/ngx_event_openssl.c:3066:13: error: ‘ERR_peek_error_line_data’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 3066 | n = ERR_peek_error_line_data(NULL, NULL, &data, &flags); | ^ In file included from src/event/ngx_event_openssl.h:16, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/err.h:425:15: note: declared here 425 | unsigned long ERR_peek_error_line_data(const char **file, int *line, | ^~~~~~~~~~~~~~~~~~~~~~~~ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_ticket_key_callback’: src/event/ngx_event_openssl.c:3976:9: error: ‘HMAC_Init_ex’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 3976 | if (HMAC_Init_ex(hctx, key[0].hmac_key, size, digest, NULL) != 1) { | ^~ In file included from /usr/include/openssl/ssl.h:37, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/hmac.h:43:27: note: declared here 43 | OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, | ^~~~~~~~~~~~ src/event/ngx_event_openssl.c:4020:9: error: ‘HMAC_Init_ex’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 4020 | if (HMAC_Init_ex(hctx, key[i].hmac_key, size, digest, NULL) != 1) { | ^~ In file included from /usr/include/openssl/ssl.h:37, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/hmac.h:43:27: note: declared here 43 | OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, | ^~~~~~~~~~~~ src/event/ngx_event_openssl.c: In function ‘ngx_openssl_engine’: src/event/ngx_event_openssl.c:5151:5: error: ‘ENGINE_by_id’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 5151 | engine = ENGINE_by_id((char *) value[1].data); | ^~~~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:336:31: note: declared here 336 | OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_by_id(const char *id); | ^~~~~~~~~~~~ src/event/ngx_event_openssl.c:5159:5: error: ‘ENGINE_set_default’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 5159 | if (ENGINE_set_default(engine, ENGINE_METHOD_ALL) == 0) { | ^~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:708:27: note: declared here 708 | OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default(ENGINE *e, unsigned int flags); | ^~~~~~~~~~~~~~~~~~ src/event/ngx_event_openssl.c:5164:9: error: ‘ENGINE_free’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 5164 | ENGINE_free(engine); | ^~~~~~~~~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:493:27: note: declared here 493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); | ^~~~~~~~~~~ src/event/ngx_event_openssl.c:5169:5: error: ‘ENGINE_free’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations] 5169 | ENGINE_free(engine); | ^~~~~~~~~~~ In file included from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:83, from src/event/ngx_event_openssl.c:9: /usr/include/openssl/engine.h:493:27: note: declared here 493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); | ^~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [objs/Makefile:995: objs/src/event/ngx_event_openssl.o] Error 1 make[1]: Leaving directory '/home/ubuntu/pingos-master/nginx' make: *** [Makefile:11: install] Error 2
06-09
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值