Nginx1.13.4 static on Debian 9 (Stretch)

Maxim Dounin mdounin at mdounin.ru
Mon Aug 14 13:44:58 UTC 2017


Hello!

On Mon, Aug 14, 2017 at 04:15:00PM +0300, Claudiu Rad wrote:

> Hello,
> 
> I'm trying a static build of nginx. Sorry if this may have been answered 
> before but I couldn't find anything closer than 
> https://trac.nginx.org/nginx/ticket/903.
> Downloaded http://nginx.org/download/nginx-1.13.4.tar.gz. In the sources 
> folder:
> 
> ./configure --prefix=/opt/nginx --with-cc-opt="-static -static-libgcc" --with-ld-opt="-Bstatic -static -static-libgcc -static-libstdc++"
> 
> Build fails with the following result
> 
> ...
> objs/ngx_modules.o \
> -Bstatic -static -static-libgcc -static-libstdc++ -ldl -lpthread -lcrypt -lpcre -lz
> objs/src/core/nginx.o: In function `ngx_load_module':
> /tmp/nginx-static/nginx-1.13.4/src/core/nginx.c:1522: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> objs/src/os/unix/ngx_process_cycle.o: In function `ngx_worker_process_init':
> /tmp/nginx-static/nginx-1.13.4/src/os/unix/ngx_process_cycle.c:835: warning: Using 'initgroups' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> objs/src/core/nginx.o: In function `ngx_set_user':
> /tmp/nginx-static/nginx-1.13.4/src/core/nginx.c:1228: warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /tmp/nginx-static/nginx-1.13.4/src/core/nginx.c:1216: warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> objs/src/core/ngx_inet.o: In function `ngx_inet_resolve_host':
> /tmp/nginx-static/nginx-1.13.4/src/core/ngx_inet.c:1127: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_generate_code':
> (.text+0x816): undefined reference to `pthread_mutex_lock'
> /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_generate_code':
> (.text+0x91b): undefined reference to `pthread_mutex_unlock'

[...]

> Am I missing anything? I tried passing various static instructions to 
> CC/LD as seen for example here: https://trac.nginx.org/nginx/ticket/903.
> 
> What's the right way to do this?

Build fails because PCRE requires `-lpthread` on your system.
Try something like 

./configure --with-ld-opt="-static -lpcre -lpthread" ...

See https://trac.nginx.org/nginx/ticket/859 for additional 
details.

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list