mirror of
https://github.com/ADD-SP/ngx_waf.git
synced 2026-04-26 14:05:52 +03:00
[GH-ISSUE #12] 无法编译 #142
Labels
No labels
MacOS
Nginx
OpenResty
Tengine
bug
documentation
enhancement
needs-investigation
pull-request
question
stale
stale
stale
timeout
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ngx_waf#142
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @toyops on GitHub (Dec 14, 2020).
Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/12
编译安装时报错。
参数 如下。
./configure
--user=www
--group=www
--prefix=/usr/local/nginx
--builddir=/usr/local/nginx/build
--sbin-path=/usr/local/nginx/sbin/nginx
--modules-path=/usr/local/nginx/modules
--pid-path=/usr/local/nginx/sbin/nginx.pid
--http-client-body-temp-path=/usr/local/nginx/temp/client
--http-proxy-temp-path=/usr/local/nginx/temp/proxy
--with-pcre=${BASEPATH}/pcre-8.42
--with-zlib=${BASEPATH}/zlib-cloudflare-1.2.8
"install.sh" 105L, 2914C
--user=www
--group=www
--prefix=/usr/local/nginx
--builddir=/usr/local/nginx/build
--sbin-path=/usr/local/nginx/sbin/nginx
--modules-path=/usr/local/nginx/modules
--pid-path=/usr/local/nginx/sbin/nginx.pid
--http-client-body-temp-path=/usr/local/nginx/temp/client
--http-proxy-temp-path=/usr/local/nginx/temp/proxy
--with-pcre=${BASEPATH}/pcre-8.42
--with-zlib=${BASEPATH}/zlib-cloudflare-1.2.8
--with-pcre-jit
--with-threads
--with-http_ssl_module
--with-http_v2_module
--with-http_gzip_static_module
--with-http_gunzip_module
--with-http_sub_module
--with-http_stub_status_module
--with-http_degradation_module
--with-http_realip_module
--with-stream
--with-stream_ssl_preread_module
--with-stream_ssl_module
--add-module=${BASEPATH}/ngx_waf
--add-module=${BASEPATH}/ngx_brotli && make
报错信息
/root/nginx/ngx_waf/src/../inc/ngx_http_waf_module_check.h: In function ‘ngx_http_waf_handler_check_white_url’:
/root/nginx/ngx_waf/src/../inc/ngx_http_waf_module_check.h:302:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < srv_conf->white_url->nelts; i++, p++) {
@ADD-SP commented on GitHub (Dec 14, 2020):
可能是编译器版本太低,不支持或者默认不开启 C99 标准。下面是两个解决方案,推荐第一个,不行再用第二个。
./configure --with-cc-opt='xxxxxx‘中追加-std=c99来开启 C99 标准。gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)。通过./configure --with-cc=PATH来指定较新的 gcc。@toyops commented on GitHub (Dec 14, 2020):
办法一已经试过了,报各种语法错误的样子。
gcc 版本是 Centos7 源自带的。
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
只能升级 gcc 来解决的话有点麻烦。
@ADD-SP commented on GitHub (Dec 14, 2020):
我记得好像可以不用升级,直接安装较新的 gcc,安装完成后老的依旧用
gcc命令,新的大概是gcc-version命令。@toyops commented on GitHub (Dec 14, 2020):
用 Software Collections(SCL)解决了,原来提供了多版本软件共存的办法。
yum install centos-release-scl scl-utils-build scl-utils -y
yum install devtoolset-9-gcc.x86_64 -y
scl enable devtoolset-9 bash
之后编译运行 nginx 就可以了,也不需要加 --with-cc-opt='-std=c99' 参数。
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
在这个版本的 gcc 下编译成功了。