﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
903	nginx 1.9.11+: Can`t build static nginx any more	Emmeran Seehuber		"I try to always be up to date with nginx, and build nginx myself as a static module. This allows me to deploy nginx to my different environments (testing, production) without any library dependency problems. Till nginx 1.9.10 this worked like Charme. 

I`ve got this directory layout for my build directory:

- nginx
  - openssl-1.0.2f
  - nginx_src

nginx_src is a git checkout of the git mirror. 


I use this script to build nginx:

{{{
#!/bin/sh
cd nginx_src/
make clean
./auto/configure \
        --with-http_ssl_module \
        --with-http_v2_module \
        --with-http_realip_module \
        --with-http_gzip_static_module \
        --without-http_scgi_module  \
        --without-http_uwsgi_module  \
        --without-http_fastcgi_module \
        --with-openssl=../openssl-1.0.2f \
        --prefix=/etc/nginx \
        --conf-path=/etc/nginx/nginx.conf \
        --error-log-path=/var/log/nginx/error.log \
        --http-client-body-temp-path=/var/lib/nginx/body \
         --http-log-path=/var/log/nginx/access.log \
         --http-proxy-temp-path=/var/lib/nginx/proxy \
         --lock-path=/var/lock/nginx.lock \
         --pid-path=/var/run/nginx.pid \
        --with-ld-opt=""-Bstatic -static -static-libgcc -static-libstdc++ -static -Bstatic""   

make
}}}

This script worked fine till 1.9.10.  Now I get this linker error:

{{{
....
        objs/src/http/modules/ngx_http_upstream_hash_module.o \
        objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \
        objs/src/http/modules/ngx_http_upstream_least_conn_module.o \
        objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
        objs/src/http/modules/ngx_http_upstream_zone_module.o \
        objs/ngx_modules.o \
        -Bstatic -static -static-libgcc -static-libstdc++ -static -Bstatic -ldl -lpthread -lcrypt -lpcre ../openssl-1.0.2f/.openssl/lib/libssl.a ../openssl-1.0.2f/.openssl/lib/libcrypto.a -lz
objs/src/core/nginx.o: In function `ngx_load_module':
/home/emmy/nginx/nginx_src/src/core/nginx.c:1453: 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':
/home/emmy/nginx/nginx_src/src/os/unix/ngx_process_cycle.c:838: 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':
/home/emmy/nginx/nginx_src/src/core/nginx.c:1182: warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/emmy/nginx/nginx_src/src/core/nginx.c:1170: 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':
/home/emmy/nginx/nginx_src/src/core/ngx_inet.c:1118: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../openssl-1.0.2f/.openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x6be): undefined reference to `dladdr'
collect2: ld gab 1 als Ende-Status zurück
make[1]: *** [objs/nginx] Fehler 1
make[1]: Verlasse Verzeichnis '/home/emmy/nginx/nginx_src'
make: *** [build] Fehler 2
}}}

If I add '-ldl' at the end of the linker command line, it works and correctly links nginx. 

{{{
....
        objs/src/http/modules/ngx_http_proxy_module.o \
        objs/src/http/modules/ngx_http_memcached_module.o \
        objs/src/http/modules/ngx_http_empty_gif_module.o \
        objs/src/http/modules/ngx_http_browser_module.o \
        objs/src/http/modules/ngx_http_upstream_hash_module.o \
        objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \
        objs/src/http/modules/ngx_http_upstream_least_conn_module.o \
        objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
        objs/src/http/modules/ngx_http_upstream_zone_module.o \
        objs/ngx_modules.o \
        -Bstatic -static -static-libgcc -static-libstdc++ -static -Bstatic -ldl -lpthread -lcrypt -lpcre ../openssl-1.0.2f/.openssl/lib/libssl.a ../openssl-1.0.2f/.openssl/lib/libcrypto.a -lz -ldl
}}}

This problem happens with the 1.9.11 tag and with current master. I did not find a way to fix this problem with configure parameters. Am I missing something? For now I just will patch the generated Makefile and append -ldl. 

Thanks and keep up the good work!"	defect	closed	major		nginx-core	1.9.x	fixed			Linux nginx-build-server 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux	"nginx version: nginx/1.9.12
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
built with OpenSSL 1.0.2f  28 Jan 2016
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --without-http_scgi_module --without-http_uwsgi_module --without-http_fastcgi_module --with-openssl=../openssl-1.0.2f --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-ld-opt='-Bstatic -static -static-libgcc -static-libstdc++ -static -Bstatic'"
