Welcome! Log In Create A New Profile

Advanced

Re: NGINX "--with-zlib=..." linker error

March 28, 2022 03:48PM
On Mon, Mar 28, 2022 at 3:35 PM Fabiano Furtado Pessoa Coelho
<fusca14@gmail.com> wrote:
>
> Hi...
>
> I'm using https://nginx.org/packages/rhel/8/SRPMS/nginx-1.20.2-1.el8.ngx.src.rpm
> to compile NGINX to RHEL 8.5, with "--with-openssl=/openssl_1_1_1n"
> parameter in the "%define BASE_CONFIGURE_ARGS" .SPEC file, and it
> works fine. The NGINX package is compiled without errors.
>
> Now I want to add the "--with-zlib=/zlib_1_2_12" parameter, to compile
> NGINX with the latest zlib version 1.2.12, and I get these linker
> errors:
>
> ...
> objs/ngx_modules.o \
> -Wl,-z,relro -Wl,-z,now -pie -ldl -lpthread -lpthread -lcrypt -lpcre
> /openssl_1_1_1n/.openssl/lib/libssl.a
> /openssl_1_1_1n/.openssl/lib/libcrypto.a -ldl -lpthread
> /zlib_1_2_12/libz.a \
> -Wl,-E
> /usr/bin/ld: /zlib_1_2_12/libz.a(deflate.o): relocation R_X86_64_32S
> against symbol `_length_code' can not be used when making a PIE
> object; recompile with -fPIC
> /usr/bin/ld: /zlib_1_2_12/libz.a(inflate.o): relocation R_X86_64_32S
> against symbol `zcfree' can not be used when making a PIE object;
> recompile with -fPIC
> /usr/bin/ld: /zlib_1_2_12/libz.a(inftrees.o): relocation R_X86_64_32S
> against `.rodata' can not be used when making a PIE object; recompile
> with -fPIC
> /usr/bin/ld: /zlib_1_2_12/libz.a(trees.o): relocation R_X86_64_32S
> against symbol `_length_code' can not be used when making a PIE
> object; recompile with -fPIC
> /usr/bin/ld: /zlib_1_2_12/libz.a(zutil.o): relocation R_X86_64_32
> against `.rodata.str1.1' can not be used when making a PIE object;
> recompile with -fPIC
> /usr/bin/ld: /zlib_1_2_12/libz.a(crc32.o): relocation R_X86_64_32S
> against `.rodata' can not be used when making a PIE object; recompile
> with -fPIC
> /usr/bin/ld: /zlib_1_2_12/libz.a(inffast.o): relocation R_X86_64_32S
> against `.rodata.str1.1' can not be used when making a PIE object;
> recompile with -fPIC
> /usr/bin/ld: final link failed: Nonrepresentable section on output
> collect2: error: ld returned 1 exit status
> ...
>
> Is there a solution for this linker issue?

Rebuild zLib. Use -fPIC when building it.

zlib is an old makefile-based library. You usually need to patch it
heavily to get it to honor CPPFLAGS, CFLAGS and CXXFLAGS. The easiest
thing to do would be open the makefile and just add the flag by hand.

Here's an example of a zlib patch to generalize the makefile so it
honors user flags:
https://github.com/noloader/Build-Scripts/blob/master/patch/zlib.patch
..

Jeff
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

NGINX "--with-zlib=..." linker error

Fabiano Furtado Pessoa Coelho March 28, 2022 03:36PM

Re: NGINX "--with-zlib=..." linker error

noloader March 28, 2022 03:48PM

Re: NGINX "--with-zlib=..." linker error

Fabiano Furtado Pessoa Coelho March 28, 2022 04:06PM

Re: NGINX "--with-zlib=..." linker error

Maxim Dounin March 28, 2022 06:10PM

Re: NGINX "--with-zlib=..." linker error

Fabiano Furtado Pessoa Coelho March 28, 2022 07:30PM

Re: NGINX "--with-zlib=..." linker error

Maxim Dounin March 29, 2022 08:08AM

Re: NGINX "--with-zlib=..." linker error

Fabiano Furtado Pessoa Coelho March 29, 2022 03:10PM

Re: NGINX "--with-zlib=..." linker error

Jim Popovitch via nginx March 29, 2022 03:30PM

Re: NGINX "--with-zlib=..." linker error

Fabiano Furtado Pessoa Coelho March 30, 2022 09:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready