Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1070 closed defect (fixed)

nginx with NJS compile error

Reported by: joaoarquimedes@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.10.x
Keywords: nginx compiler njs error Cc:
uname -a: Linux localhost.localdomain 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

Description

What's wrong compiling nginx with njs? Example:

Download:

# cd /usr/src/
# git clone https://github.com/nginx/njs.git
# wget http://nginx.org/download/nginx-1.10.1.tar.gz
# tar -zxf nginx-1.10.1.tar.gz

Configure:

# cd nginx-1.10.1
# ./configure --add-dynamic-module=../njs/nginx
...
adding module in ../njs/nginx
 + ngx_js_module was configured
...
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

And make error:

# make
...
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../njs/nginx/../nxt -I ../njs/nginx/../njs -I ../njs/nginx/../nxt -I ../njs/nginx/../njs -I objs -I src/http -I src/http/modules \
    -o objs/addon/nginx/ngx_stream_js_module.o \
    ../njs/nginx/ngx_stream_js_module.c
../njs/nginx/ngx_stream_js_module.c:10:24: fatal error: ngx_stream.h: no such file or directory
 #include <ngx_stream.h>
                        ^
compilation terminated.
make[1]: ** [objs/addon/nginx/ngx_stream_js_module.o] Erro 1
make[1]: Saindo do diretório `/usr/src/nginx-1.10.1'
make: ** [build] Erro 2

I did as the documentation procedure. I did the compilation in other way, see:

cd /usr/src/njs/nginx
# gcc -c -I /usr/src/nginx-1.10.1/src/core -I /usr/src/nginx-1.10.1/src/stream -I /usr/src/nginx-1.10.1/objs -I /usr/src/nginx-1.10.1/src/os/unix -I /usr/src/nginx-1.10.1/src/http -I /usr/src/nginx-1.10.1/src/event -I /usr/src/nginx-1.10.1/src/http/modules -I /usr/src/njs/nxt -I /usr/src/njs/njs ngx_http_js_module.c

Result:

# file ngx_http_js_module.o
ngx_http_js_module.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

But when I compile the ngx_stream_js_module.c. It Shows another error, see sample:

# gcc -c -I /usr/src/nginx-1.10.1/src/core -I /usr/src/nginx-1.10.1/src/stream -I /usr/src/nginx-1.10.1/objs -I /usr/src/nginx-1.10.1/src/os/unix -I /usr/src/nginx-1.10.1/src/http -I /usr/src/nginx-1.10.1/src/event -I /usr/src/nginx-1.10.1/src/http/modules -I /usr/src/njs/nxt -I /usr/src/njs/njs ngx_stream_js_module.c
ngx_stream_js_module.c:53:5: error: unknown type name ‘ngx_stream_variable_value_t’
     ngx_stream_variable_value_t *v, uintptr_t data);
     ^
ngx_stream_js_module.c:105:5: warning: initialization from incompatible pointer type [enabled by default]
     ngx_stream_js_create_srv_conf, /* create server configuration */
     ^
ngx_stream_js_module.c:105:5: warning: (near initialization for ‘ngx_stream_js_module_ctx.merge_srv_conf’) [enabled by default]
ngx_stream_js_module.c:106:5: warning: excess elements in struct initializer [enabled by default]
     ngx_stream_js_merge_srv_conf,  /* merge server configuration */
     ^
ngx_stream_js_module.c:106:5: warning: (near initialization for ‘ngx_stream_js_module_ctx’) [enabled by default]
ngx_stream_js_module.c:194:49: error: unknown type name ‘ngx_stream_variable_value_t’
 ngx_stream_js_variable(ngx_stream_session_t *s, ngx_stream_variable_value_t *v,
                                                 ^
ngx_stream_js_module.c: In function ‘ngx_stream_js_ext_get_variable’:
ngx_stream_js_module.c:402:5: error: unknown type name ‘ngx_stream_variable_value_t’
     ngx_stream_variable_value_t  *vv;
     ^
ngx_stream_js_module.c:412:8: warning: assignment makes pointer from integer without a cast [enabled by default]
     vv = ngx_stream_get_variable(s, &name, key);
        ^
ngx_stream_js_module.c:413:25: error: request for member ‘not_found’ in something not a structure or union
     if (vv == NULL || vv->not_found) {
                         ^
ngx_stream_js_module.c:417:43: error: request for member ‘data’ in something not a structure or union
     return njs_string_create(vm, value, vv->data, vv->len, 0);
                                           ^
ngx_stream_js_module.c:417:53: error: request for member ‘len’ in something not a structure or union
     return njs_string_create(vm, value, vv->data, vv->len, 0);
                                                     ^
ngx_stream_js_module.c: In function ‘ngx_stream_js_set’:
ngx_stream_js_module.c:562:5: error: unknown type name ‘ngx_stream_variable_t’
     ngx_stream_variable_t  *v;
     ^
ngx_stream_js_module.c:575:48: error: ‘NGX_STREAM_VAR_CHANGEABLE’ undeclared (first use in this function)
     v = ngx_stream_add_variable(cf, &value[1], NGX_STREAM_VAR_CHANGEABLE);
                                                ^
ngx_stream_js_module.c:575:48: note: each undeclared identifier is reported only once for each function it appears in
ngx_stream_js_module.c:587:6: error: request for member ‘get_handler’ in something not a structure or union
     v->get_handler = ngx_stream_js_variable;
      ^
ngx_stream_js_module.c:587:22: error: ‘ngx_stream_js_variable’ undeclared (first use in this function)
     v->get_handler = ngx_stream_js_variable;
                      ^
ngx_stream_js_module.c:588:6: error: request for member ‘data’ in something not a structure or union
     v->data = (uintptr_t) fname;
      ^

Change History (3)

comment:1 by Roman Arutyunyan, 8 years ago

Looks like njs module config should be fixed.
As a workaround, you can compile nginx with stream using the --with-stream configure option.

comment:2 by Roman Arutyunyan, 8 years ago

Resolution: fixed
Status: newclosed

comment:3 by joaoarquimedes@…, 8 years ago

Thanks, without stream options it works. But with "--with-stream" it makes an error, look:

./configure --with-stream --add-module=../njs/nginx

...

../njs/nginx/ngx_stream_js_module.c
../njs/nginx/ngx_stream_js_module.c:68:5: error: unknown type name ‘ngx_stream_variable_value_t’
     ngx_stream_variable_value_t *v, uintptr_t data);
     ^
../njs/nginx/ngx_stream_js_module.c:147:5: error: initialization from incompatible pointer type [-Werror]
     ngx_stream_js_init,            /* postconfiguration */

...

cc1: all warnings being treated as errors
make[1]: *** [objs/addon/nginx/ngx_stream_js_module.o] Error 1
make[1]: Leaving directory `/usr/src/nginx-1.10.1'
make: *** [build] Error 2

Can you fix it too?

Note: See TracTickets for help on using tickets.