Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#2599 closed defect (invalid)

Nginx 1.24 building from source with pcre2 on Ubuntu leading to issues

Reported by: Umar Noor Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.25.x
Keywords: Cc:
uname -a: Linux anadev001 6.5.0-15-generic #15~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 12 18:54:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx-1.24.0.tar.gz

Description (last modified by Maxim Dounin)

Ubuntu Version: Linux anadev001 6.5.0-15-generic #15~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 12 18:54:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

make version: GNU Make 4.3
Nginx version: nginx-1.24.0.tar.gz
PCRE2 Version: pcre2-10.42.tar.gz
gcc version: gcc version 11.4.0

Getting the below compilation issues using the above configuration:

 make -f objs/Makefile
gcc -c -fPIC -I/home/umarsam/projectwork/nginx/../pcre/src/include -I/home/umarsam/projectwork/nginx/../zlib/prod/include -I/home/umarsam/projectwork/nginx/../gd/prod/include -I/home/umarsam/projectwork/nginx/../openssl/prod/include -I.  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /home/umarsam/projectwork/nginx/../pcre/prod/include -I /home/umarsam/projectwork/nginx/../openssl/prod/include -I /home/umarsam/projectwork/nginx/../zlib/prod/include -I /home/umarsam/projectwork/gd/prod/include -I objs -I src/http -I src/http/modules -I src/http/v2 \
        -o objs/src/http/modules/ngx_http_rewrite_module.o \
        src/http/modules/ngx_http_rewrite_module.c
src/http/modules/ngx_http_rewrite_module.c: In function ‘ngx_http_rewrite’:
src/http/modules/ngx_http_rewrite_module.c:309:5: error: unknown type name ‘ngx_http_script_regex_code_t’; did you mean ‘ngx_http_script_file_code_t’?
  309 |     ngx_http_script_regex_code_t      *regex;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     ngx_http_script_file_code_t
src/http/modules/ngx_http_rewrite_module.c:310:5: error: unknown type name ‘ngx_http_script_regex_end_code_t’; did you mean ‘ngx_http_script_return_code_t’?
  310 |     ngx_http_script_regex_end_code_t  *regex_end;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     ngx_http_script_return_code_t
src/http/modules/ngx_http_rewrite_module.c:314:47: error: ‘ngx_http_script_regex_code_t’ undeclared (first use in this function); did you mean ‘ngx_http_script_file_code_t’?
  314 |                                        sizeof(ngx_http_script_regex_code_t));
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                               ngx_http_script_file_code_t
src/http/modules/ngx_http_rewrite_module.c:314:47: note: each undeclared identifier is reported only once for each function it appears in
src/http/modules/ngx_http_rewrite_module.c:336:10: error: request for member ‘regex’ in something not a structure or union
  336 |     regex->regex = ngx_http_regex_compile(cf, &rc);
      |          ^~
src/http/modules/ngx_http_rewrite_module.c:336:20: warning: implicit declaration of function ‘ngx_http_regex_compile’; did you mean ‘ngx_regex_compile’? [-Wimplicit-function-declaration]
  336 |     regex->regex = ngx_http_regex_compile(cf, &rc);
      |                    ^~~~~~~~~~~~~~~~~~~~~~
      |                    ngx_regex_compile
src/http/modules/ngx_http_rewrite_module.c:337:14: error: request for member ‘regex’ in something not a structure or union
  337 |     if (regex->regex == NULL) {
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:341:10: error: request for member ‘code’ in something not a structure or union
  341 |     regex->code = ngx_http_script_regex_start_code;
      |          ^~
src/http/modules/ngx_http_rewrite_module.c:341:19: error: ‘ngx_http_script_regex_start_code’ undeclared (first use in this function); did you mean ‘ngx_http_script_start_code’?
  341 |     regex->code = ngx_http_script_regex_start_code;
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   ngx_http_script_start_code
src/http/modules/ngx_http_rewrite_module.c:342:10: error: request for member ‘uri’ in something not a structure or union
  342 |     regex->uri = 1;
      |          ^~
src/http/modules/ngx_http_rewrite_module.c:343:10: error: request for member ‘name’ in something not a structure or union
  343 |     regex->name = value[1];
      |          ^~
src/http/modules/ngx_http_rewrite_module.c:351:14: error: request for member ‘add_args’ in something not a structure or union
  351 |         regex->add_args = 1;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:360:14: error: request for member ‘status’ in something not a structure or union
  360 |         regex->status = NGX_HTTP_MOVED_TEMPORARILY;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:361:14: error: request for member ‘redirect’ in something not a structure or union
  361 |         regex->redirect = 1;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:370:18: error: request for member ‘break_cycle’ in something not a structure or union
  370 |             regex->break_cycle = 1;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:374:18: error: request for member ‘status’ in something not a structure or union
  374 |             regex->status = NGX_HTTP_MOVED_TEMPORARILY;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:375:18: error: request for member ‘redirect’ in something not a structure or union
  375 |             regex->redirect = 1;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:379:18: error: request for member ‘status’ in something not a structure or union
  379 |             regex->status = NGX_HTTP_MOVED_PERMANENTLY;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:380:18: error: request for member ‘redirect’ in something not a structure or union
  380 |             regex->redirect = 1;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:394:24: error: request for member ‘lengths’ in something not a structure or union
  394 |     sc.lengths = &regex->lengths;
      |                        ^~
src/http/modules/ngx_http_rewrite_module.c:399:29: error: request for member ‘redirect’ in something not a structure or union
  399 |     sc.compile_args = !regex->redirect;
      |                             ^~
src/http/modules/ngx_http_rewrite_module.c:407:10: error: request for member ‘size’ in something not a structure or union
  407 |     regex->size = sc.size;
      |          ^~
src/http/modules/ngx_http_rewrite_module.c:408:10: error: request for member ‘args’ in something not a structure or union
  408 |     regex->args = sc.args;
      |          ^~
src/http/modules/ngx_http_rewrite_module.c:411:14: error: request for member ‘lengths’ in something not a structure or union
  411 |         regex->lengths = NULL;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:415:46: error: ‘ngx_http_script_regex_end_code_t’ undeclared (first use in this function); did you mean ‘ngx_http_script_return_code_t’?
  415 |                                       sizeof(ngx_http_script_regex_end_code_t),
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                              ngx_http_script_return_code_t
src/http/modules/ngx_http_rewrite_module.c:421:14: error: request for member ‘code’ in something not a structure or union
  421 |     regex_end->code = ngx_http_script_regex_end_code;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:421:23: error: ‘ngx_http_script_regex_end_code’ undeclared (first use in this function); did you mean ‘ngx_http_script_return_code’?
  421 |     regex_end->code = ngx_http_script_regex_end_code;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                       ngx_http_script_return_code
src/http/modules/ngx_http_rewrite_module.c:422:14: error: request for member ‘uri’ in something not a structure or union
  422 |     regex_end->uri = regex->uri;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:422:27: error: request for member ‘uri’ in something not a structure or union
  422 |     regex_end->uri = regex->uri;
      |                           ^~
src/http/modules/ngx_http_rewrite_module.c:423:14: error: request for member ‘args’ in something not a structure or union
  423 |     regex_end->args = regex->args;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:423:28: error: request for member ‘args’ in something not a structure or union
  423 |     regex_end->args = regex->args;
      |                            ^~
src/http/modules/ngx_http_rewrite_module.c:424:14: error: request for member ‘add_args’ in something not a structure or union
  424 |     regex_end->add_args = regex->add_args;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:424:32: error: request for member ‘add_args’ in something not a structure or union
  424 |     regex_end->add_args = regex->add_args;
      |                                ^~
src/http/modules/ngx_http_rewrite_module.c:425:14: error: request for member ‘redirect’ in something not a structure or union
  425 |     regex_end->redirect = regex->redirect;
      |              ^~
src/http/modules/ngx_http_rewrite_module.c:425:32: error: request for member ‘redirect’ in something not a structure or union
  425 |     regex_end->redirect = regex->redirect;
      |                                ^~
src/http/modules/ngx_http_rewrite_module.c:436:10: error: request for member ‘next’ in something not a structure or union
  436 |     regex->next = (u_char *) lcf->codes->elts + lcf->codes->nelts
      |          ^~
src/http/modules/ngx_http_rewrite_module.c: In function ‘ngx_http_rewrite_if_condition’:
src/http/modules/ngx_http_rewrite_module.c:658:5: error: unknown type name ‘ngx_http_script_regex_code_t’; did you mean ‘ngx_http_script_file_code_t’?
  658 |     ngx_http_script_regex_code_t  *regex;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     ngx_http_script_file_code_t
src/http/modules/ngx_http_rewrite_module.c:756:49: error: ‘ngx_http_script_regex_code_t’ undeclared (first use in this function); did you mean ‘ngx_http_script_file_code_t’?
  756 |                                          sizeof(ngx_http_script_regex_code_t));
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                 ngx_http_script_file_code_t
src/http/modules/ngx_http_rewrite_module.c:770:18: error: request for member ‘regex’ in something not a structure or union
  770 |             regex->regex = ngx_http_regex_compile(cf, &rc);
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:771:22: error: request for member ‘regex’ in something not a structure or union
  771 |             if (regex->regex == NULL) {
      |                      ^~
src/http/modules/ngx_http_rewrite_module.c:775:18: error: request for member ‘code’ in something not a structure or union
  775 |             regex->code = ngx_http_script_regex_start_code;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:775:27: error: ‘ngx_http_script_regex_start_code’ undeclared (first use in this function); did you mean ‘ngx_http_script_start_code’?
  775 |             regex->code = ngx_http_script_regex_start_code;
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                           ngx_http_script_start_code
src/http/modules/ngx_http_rewrite_module.c:776:18: error: request for member ‘next’ in something not a structure or union
  776 |             regex->next = sizeof(ngx_http_script_regex_code_t);
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:777:18: error: request for member ‘test’ in something not a structure or union
  777 |             regex->test = 1;
      |                  ^~
src/http/modules/ngx_http_rewrite_module.c:779:22: error: request for member ‘negative_test’ in something not a structure or union
  779 |                 regex->negative_test = 1;
      |                      ^~
src/http/modules/ngx_http_rewrite_module.c:781:18: error: request for member ‘name’ in something not a structure or union
  781 |             regex->name = value[last];
      |                  ^~


After having a look in the code the below 2 structures causing this are defined in teh directives with PCRE only and not with PCRE2

#if (NGX_PCRE)

typedef struct {
    ngx_http_script_code_pt     code;
    ngx_http_regex_t           *regex;
    ngx_array_t                *lengths;
    uintptr_t                   size;
    uintptr_t                   status;
    uintptr_t                   next;

    unsigned                    test:1;
    unsigned                    negative_test:1;
    unsigned                    uri:1;
    unsigned                    args:1;

    /* add the r->args to the new arguments */
    unsigned                    add_args:1;

    unsigned                    redirect:1;
    unsigned                    break_cycle:1;

    ngx_str_t                   name;
} ngx_http_script_regex_code_t;


typedef struct {
    ngx_http_script_code_pt     code;

    unsigned                    uri:1;
    unsigned                    args:1;

    /* add the r->args to the new arguments */
    unsigned                    add_args:1;

    unsigned                    redirect:1;
} ngx_http_script_regex_end_code_t;

#endif

Could you please let me know if this is the right way of compiling or niginx1.24 does not support PCRE2 library on Ubuntu....

Change History (6)

comment:1 by Maxim Dounin, 10 months ago

Description: modified (diff)

Compilation of nginx with PCRE2 is supported staring with nginx 1.21.5. And the NGX_PCRE macro is defined for both PCRE and PCRE2, see auto/lib/pcre/conf.

The gcc arguments as shown, notably -I/home/umarsam/projectwork/nginx/../pcre/src/include and -I /home/umarsam/projectwork/nginx/../pcre/prod/include, suggest you are doing something wrong with the configure arguments. Please show configure arguments you are using and configure output.

comment:2 by Umar Noor, 10 months ago

Thanks for the response.

Please see the below segment of my makefile for building nginx

PCRE_LIB=$(PCRE_DIRECTORY)/lib
ZLIB_LIB=$(ZLIB_DIRECTORY)/lib
OPENSSL_LIB=$(OPENSSL_DIRECTORY)/lib64

CONFIGURE_OPTIONS_LINUX= --prefix=$(DIR_PROD)    --with-pcre=$(PCRE_LIB)  --with-zlib=$(ZLIB_LIB)   --with-openssl=$(OPENSSL_LIB) \
                         --with-http_ssl_module  --with-http_v2_module    --with-stream=dynamic     --with-http_addition_module   \
                         --with-http_mp4_module  --with-http_image_filter_module=dynamic

comment:3 by Umar Noor, 10 months ago

COnfigure OUtput

umarsam@anadev001:~/projectwork/nginx$ make
Build Dir set to /home/umarsam/projectwork/nginx/src
/bin/sh: 1: [: missing ]
Note: Parallel builds are turned off as it is not supported for this component
Executing Patch: /usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/auto/lib/libgd/conf < /home/umarsam/projectwork/nginx/patch/nginx_gd.patch
make CC=gcc CPP=g++ CFLAGS=" -fPIC -I/home/umarsam/projectwork/nginx/../pcre/prod/include -I/home/umarsam/projectwork/nginx/../zlib/prod/include -I/home/umarsam/projectwork/nginx/../gd/prod/include -I/home/umarsam/projectwork/nginx/../openssl/prod/include -I." CXXFLAGS=" -fPIC -I/home/umarsam/projectwork/nginx/../pcre/prod/include -I/home/umarsam/projectwork/nginx/../zlib/prod/include -I/home/umarsam/projectwork/nginx/../gd/prod/include -I/home/umarsam/projectwork/nginx/../openssl/prod/include -I." LIBS=" -L/home/umarsam/projectwork/nginx/../pcre/prod/lib -L/home/umarsam/projectwork/nginx/../zlib/prod/lib -L/home/umarsam/projectwork/nginx/../gd/prod/lib -L/home/umarsam/projectwork/nginx/../openssl/prod/lib64 -lpcre2-8 -lz -lgd -lssl" -j 1 -f /home/umarsam/projectwork/nginx/Makefile unpack configure
make[1]: Entering directory '/home/umarsam/projectwork/nginx'
cd /home/umarsam/projectwork/nginx/src && /usr/bin/gzip -d -c /home/umarsam/projectwork/nginx/distro/nginx-1.24.0.tar.gz | tar xpf -
find /home/umarsam/projectwork/nginx/src/nginx-1.24.0 -type d -print | xargs chmod g+w
/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/auto/lib/libgd/conf < /home/umarsam/projectwork/nginx/patch/nginx_gd.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/auto/lib/libgd/conf
cd /home/umarsam/projectwork/nginx/src/nginx-1.24.0 && ./configure --prefix=/home/umarsam/projectwork/nginx/prod    --with-pcre=/home/umarsam/projectwork/nginx/../pcre/prod/lib  --with-zlib=/home/umarsam/projectwork/nginx/../zlib/prod/lib   --with-openssl=/home/umarsam/projectwork/nginx/../openssl/prod/lib64 --with-http_ssl_module  --with-http_v2_module    --with-stream=dynamic     --with-http_addition_module --with-http_mp4_module  --with-http_image_filter_module=dynamic
checking for OS
 + Linux 6.5.0-15-generic x86_64
checking for C compiler ... found
 + using GNU C compiler
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for eventfd() ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for UDP_SEGMENT ... found
checking for nobody group ... not found
checking for nogroup group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for strerrordesc_np() ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for ioctl(FIONREAD) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for GD library ... not found
checking for GD library in /usr/local/ ... found
checking for GD WebP support ... found
creating objs/Makefile

Configuration summary
  + using PCRE library: /home/umarsam/projectwork/nginx/../pcre/prod/lib
  + using OpenSSL library: /home/umarsam/projectwork/nginx/../openssl/prod/lib64
  + using zlib library: /home/umarsam/projectwork/nginx/../zlib/prod/lib

  nginx path prefix: "/home/umarsam/projectwork/nginx/prod"
  nginx binary file: "/home/umarsam/projectwork/nginx/prod/sbin/nginx"
  nginx modules path: "/home/umarsam/projectwork/nginx/prod/modules"
  nginx configuration prefix: "/home/umarsam/projectwork/nginx/prod/conf"
  nginx configuration file: "/home/umarsam/projectwork/nginx/prod/conf/nginx.conf"
  nginx pid file: "/home/umarsam/projectwork/nginx/prod/logs/nginx.pid"
  nginx error log file: "/home/umarsam/projectwork/nginx/prod/logs/error.log"
  nginx http access log file: "/home/umarsam/projectwork/nginx/prod/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"

/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/ngx_auto_config.h < /home/umarsam/projectwork/nginx/patch/ngx_auto_config.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/ngx_auto_config.h
/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/src/core/ngx_regex.c < /home/umarsam/projectwork/nginx/patch/ngx_regex.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/src/core/ngx_regex.c
/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/Makefile < /home/umarsam/projectwork/nginx/patch/obj_makefile.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/Makefile
make[1]: Leaving directory '/home/umarsam/projectwork/nginx'
make CC=gcc CPP=g++ CFLAGS=" -fPIC -I/home/umarsam/projectwork/nginx/../pcre/prod/include -I/home/umarsam/projectwork/nginx/../zlib/prod/include -I/home/umarsam/projectwork/nginx/../gd/prod/include -I/home/umarsam/projectwork/nginx/../openssl/prod/include -I." CXXFLAGS=" -fPIC -I/home/umarsam/projectwork/nginx/../pcre/prod/include -I/home/umarsam/projectwork/nginx/../zlib/prod/include -I/home/umarsam/projectwork/nginx/../gd/prod/include -I/home/umarsam/projectwork/nginx/../openssl/prod/include -I." LIBS=" -L/home/umarsam/projectwork/nginx/../pcre/prod/lib -L/home/umarsam/projectwork/nginx/../zlib/prod/lib -L/home/umarsam/projectwork/nginx/../gd/prod/lib -L/home/umarsam/projectwork/nginx/../openssl/prod/lib64 -lpcre2-8 -lz -lgd -lssl" build
make[1]: Entering directory '/home/umarsam/projectwork/nginx'
cd /home/umarsam/projectwork/nginx/src/nginx-1.24.0 && unset MAKELEVEL MAKEFLAGS && make -j1
make -f objs/Makefile
make[1]: Entering directory '/home/umarsam/projectwork/nginx/src/nginx-1.24.0'

comment:4 by Maxim Dounin, 10 months ago

Resolution: invalid
Status: newclosed

The --with-pcre=/home/umarsam/projectwork/nginx/../pcre/prod/lib in your configure arguments suggests that you are most likely using it wrong. Note that --with-pcre= argument specifies path to PCRE/PCRE2 library sources, not a compiled library files. If you want nginx to use library which is already compiled, use --with-cc-opt="-I..." and --with-ld-opt="-L..." as appropriate.

Further, it looks like you are patching nginx configuration result (objs/ngx_auto_config.h), as well as regex code (src/core/ngx_regex.c) and Makefile:

/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/ngx_auto_config.h < /home/umarsam/projectwork/nginx/patch/ngx_auto_config.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/ngx_auto_config.h
/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/src/core/ngx_regex.c < /home/umarsam/projectwork/nginx/patch/ngx_regex.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/src/core/ngx_regex.c
/usr/bin/patch /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/Makefile < /home/umarsam/projectwork/nginx/patch/obj_makefile.patch
patching file /home/umarsam/projectwork/nginx/src/nginx-1.24.0/objs/Makefile

Most likely, some of these patches are causing build issues you are seeing. Consider re-building nginx without any patches, it should work out of the box (assuming correct configure arguments).

If you need further help with building nginx, consider using support options available.

comment:5 by Umar Noor, 10 months ago

Build is successful but the linking is not happening with the libraries suggested using --with-ccp-opt and --with-ld-opt

Configure options

CONFIGURE_OPTIONS_LINUX= --prefix=$(DIR_PROD)    \
                         --with-http_ssl_module  --with-http_v2_module    --with-stream=dynamic     --with-http_addition_module   \
                         --with-http_mp4_module  --with-http_image_filter_module=dynamic                                          \
                         --with-cc-opt=" -I $(PCRE_DIRECTORY)/include -I $(ZLIB_DIRECTORY)/include -I $(LIBGD_DIRECTORY)/include -I $(OPENSSL_DIRECTORY)/include -I ."  \
                         --with-ld-opt=" -L $(PCRE_DIRECTORY)/lib -L $(ZLIB_DIRECTORY)/lib -L $(LIBGD_DIRECTORY)/lib -L $(OPENSSL_DIRECTORY)/lib64 -lpcre2-8 -lz -lgd -lssl"


umarsam@anadev001:~/projectwork/nginx/prod/sbin$ ls -lrt
total 1648
-rwxrwxr-x 1 umarsam umarsam 1684576 Feb 10 00:07 nginx
umarsam@anadev001:~/projectwork/nginx/prod/sbin$ ldd nginx
        linux-vdso.so.1 (0x00007fffbcdb4000)
        libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f8223886000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f822386a000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f82237c6000)
        libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f822378c000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f8223200000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8222e00000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8223ac5000)

Please advise.

comment:6 by Maxim Dounin, 10 months ago

If you want dynamic linker to dynamically link a program with shared libraries which are not in the default library search path, you have to instruct the linker where to find these libraries. This is normally done either with the LD_LIBRARY_PATH environment variable, or by hardcoding paths into the binary during linking with the -R ld option.

Alternatively, you can consider compiling the program with static libraries instead - this is what nginx does itself when it is asked to compile a particular library from sources, such as by --with-pcre= or by --with-openssl=.

Note: See TracTickets for help on using tickets.