Opened 4 years ago

Closed 4 years ago

#2020 closed defect (invalid)

Problem with statically linking Nginx

Reported by: andrewfv86@… Owned by:
Priority: trivial Milestone:
Component: documentation Version: 1.19.x
Keywords: Cc:
uname -a: Linux 2.6.32-754.30.2.el6.x86_64 #1 SMP Wed Jun 10 11:14:37 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: ./configure --prefix=nginx-static --with-cc-opt="-static -static-libgcc" \
--with-ld-opt="-static" --with-cpu-opt=generic --with-pcre \
--with-mail --with-ipv6 --with-poll_module --with-select_module \
--with-select_module --with-poll_module \
--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_auth_request_module \
--with-http_random_index_module --with-http_secure_link_module \
--with-http_degradation_module --with-http_stub_status_module \
--with-mail --with-mail_ssl_module --with-openssl=./openssl-1.1.1g

Description

Hello,

When building nginx into one static file, I get an error:

./configure --prefix=nginx-static --with-cc-opt="-static -static-libgcc" \

--with-ld-opt="-static" --with-cpu-opt=generic --with-pcre \
--with-mail --with-ipv6 --with-poll_module --with-select_module \
--with-select_module --with-poll_module \
--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_auth_request_module \
--with-http_random_index_module --with-http_secure_link_module \
--with-http_degradation_module --with-http_stub_status_module \
--with-mail --with-mail_ssl_module --with-openssl=./openssl-1.1.1g

....

checking for OS

+ Linux 2.6.32-754.30.2.el6.x86_64 x86_64

checking for C compiler ... found

+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)

checking for gcc -pipe switch ... found
checking for --with-ld-opt="-static" ... not found
./configure: error: the invalid value in --with-ld-opt="-static"

The problem is reproduced on CentOS release 6.10 (Final)

How can I correctly specify options to the linker (--with-ld-opt) to include all dependent libraries in nginx?

Change History (1)

comment:1 by Maxim Dounin, 4 years ago

Resolution: invalid
Status: newclosed

Correct options depend on your operating system, compiler used, and libraries used. The objs/autoconf.err file might be helpful to find out details of the particular errors reported. The particular error you are seeing on CentOS 6 is likely due to no glibc static libraries installed, consider using yum install glibc-static to install them.

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

Note: See TracTickets for help on using tickets.