Project

General

Profile

[Solved] Static binary only

Added by MapHtH about 5 years ago

Hello everyone,

I'm having trouble compiling the lighttpd 1.4.53 binary statically, and I don't mean linking modules statically, but linking dependencies statically with lighttpd used by the modules.

Does anyone know how to do this?

I'm trying to compile on TinyCore 10, 4.19 kernel, gcc 8.20, but I don't think it would matter.

This is the config I'm using:

LDFLAGS="-static" \
PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig \
PCRE_LIBS="$PREFIX/lib/libpcre.a" \
PCRECONFIG="$PREFIX/bin/pcre-config" \
./configure --prefix=$PREFIX --libdir=$PREFIX/share/lighttpd/plugins --with-zlib --with-bzip2 --with-openssl

Now, the config goes to the point of looking for openssl libcrypto.a and finds it but it outputs this (this also happens with a few other modules I've tested but not with all of them (zlib, bzip2, libxml, and some others work by linking static libraries)):

configure:16412: checking for OpenSSL
configure:16423: result: yes
configure:16433: checking custom include directory for openssl
configure:16447: result: no
configure:16453: checking custom lib directory for openssl
configure:16467: result: no
configure:16485: checking openssl/ssl.h usability
configure:16485: gcc -c -g -O2  -D_REENTRANT conftest.c >&5
configure:16485: $? = 0
configure:16485: result: yes
configure:16485: checking openssl/ssl.h presence
configure:16485: gcc -E  -D_REENTRANT conftest.c
configure:16485: $? = 0
configure:16485: result: yes
configure:16485: checking for openssl/ssl.h
configure:16485: result: yes
configure:16499: checking for BIO_f_base64 in -lcrypto
configure:16524: gcc -o conftest -g -O2  -D_REENTRANT -static conftest.c -lcrypto   >&5
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
b_addr.c:(.text+0xe73): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
b_sock.c:(.text+0x75): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x5f): undefined reference to `pthread_rwlock_init'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0xa5): undefined reference to `pthread_rwlock_rdlock'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0xd5): undefined reference to `pthread_rwlock_wrlock'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0x105): undefined reference to `pthread_rwlock_unlock'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0x13b): undefined reference to `pthread_rwlock_destroy'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0x17a): undefined reference to `pthread_once'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0x1aa): undefined reference to `pthread_key_create'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0x1d7): undefined reference to `pthread_getspecific'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0x1fc): undefined reference to `pthread_setspecific'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0x227): undefined reference to `pthread_key_delete'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `openssl_init_fork_handlers':
threads_pthread.c:(.text+0x2be): undefined reference to `pthread_once'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `zlib_stateful_expand_block':
c_zlib.c:(.text+0x47): undefined reference to `inflate'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `zlib_stateful_compress_block':
c_zlib.c:(.text+0xba): undefined reference to `deflate'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `zlib_stateful_finish':
c_zlib.c:(.text+0xf9): undefined reference to `inflateEnd'
/usr/local/bin/ld: c_zlib.c:(.text+0x104): undefined reference to `deflateEnd'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `zlib_stateful_init':
c_zlib.c:(.text+0x1f5): undefined reference to `inflateInit_'
/usr/local/bin/ld: c_zlib.c:(.text+0x24d): undefined reference to `deflateInit_'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `bio_zlib_ctrl':
c_zlib.c:(.text+0x4b5): undefined reference to `deflate'
/usr/local/bin/ld: c_zlib.c:(.text+0x5e7): undefined reference to `zError'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `bio_zlib_write':
c_zlib.c:(.text+0x6e1): undefined reference to `deflate'
/usr/local/bin/ld: c_zlib.c:(.text+0x757): undefined reference to `zError'
/usr/local/bin/ld: c_zlib.c:(.text+0x801): undefined reference to `deflateInit_'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `bio_zlib_read':
c_zlib.c:(.text+0x902): undefined reference to `inflate'
/usr/local/bin/ld: c_zlib.c:(.text+0x957): undefined reference to `zError'
/usr/local/bin/ld: c_zlib.c:(.text+0x9ea): undefined reference to `inflateInit_'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(c_zlib.o): in function `bio_zlib_free':
c_zlib.c:(.text+0xa6e): undefined reference to `inflateEnd'
/usr/local/bin/ld: c_zlib.c:(.text+0xa9c): undefined reference to `deflateEnd'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x16): undefined reference to `dlopen'
/usr/local/bin/ld: dso_dlfcn.c:(.text+0x2d): undefined reference to `dlsym'
/usr/local/bin/ld: dso_dlfcn.c:(.text+0x37): undefined reference to `dlclose'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x1f7): undefined reference to `dlsym'
/usr/local/bin/ld: dso_dlfcn.c:(.text+0x29e): undefined reference to `dlerror'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_load':
dso_dlfcn.c:(.text+0x320): undefined reference to `dlopen'
/usr/local/bin/ld: dso_dlfcn.c:(.text+0x3a1): undefined reference to `dlclose'
/usr/local/bin/ld: dso_dlfcn.c:(.text+0x3db): undefined reference to `dlerror'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x490): undefined reference to `dladdr'
/usr/local/bin/ld: dso_dlfcn.c:(.text+0x549): undefined reference to `dlerror'
/usr/local/bin/ld: /usr/local/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_unload':
dso_dlfcn.c:(.text+0x731): undefined reference to `dlclose'
/usr/local/bin/ld: /tmp/tcloop/gcc/usr/local/bin/../lib/gcc/i486-pc-linux-gnu/8.2.0/libgcc_eh.a(unwind-dw2.o): in function `uw_init_context_1':
(.text+0x1308): undefined reference to `pthread_once'
collect2: error: ld returned 1 exit status
configure:16524: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "lighttpd" 
| #define PACKAGE_TARNAME "lighttpd" 
| #define PACKAGE_VERSION "1.4.53" 
| #define PACKAGE_STRING "lighttpd 1.4.53" 
| #define PACKAGE_BUGREPORT "contact@lighttpd.net" 
| #define PACKAGE_URL "" 
| #define PACKAGE "lighttpd" 
| #define VERSION "1.4.53" 
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define __EXTENSIONS__ 1
| #define _ALL_SOURCE 1
| #define _GNU_SOURCE 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define _TANDEM_SOURCE 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/" 
| #define STDC_HEADERS 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_GETOPT_H 1
| #define HAVE_POLL_H 1
| #define HAVE_PWD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_EPOLL_H 1
| #define HAVE_SYS_MMAN_H 1
| #define HAVE_SYS_POLL_H 1
| #define HAVE_SYS_PRCTL_H 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_SYS_SELECT_H 1
| #define HAVE_SYS_SENDFILE_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_SYS_UIO_H 1
| #define HAVE_SYS_UN_H 1
| #define HAVE_SYSLOG_H 1
| #define HAVE_UUID_UUID_H 1
| #define HAVE_STRUCT_TM_GMTOFF 1
| #define HAVE_SOCKLEN_T 1
| #define HAVE_DLFCN_H 1
| #define HAVE_LIBDL 1
| #define HAVE_DLFCN_H 1
| #define HAVE_OPENSSL_SSL_H 1
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C" 
| #endif
| char BIO_f_base64 ();
| int
| main ()
| {
| return BIO_f_base64 ();
|   ;
|   return 0;
| }
configure:16533: result: no
configure:16538: error: openssl crypto library not found. install it or build without --with-openssl

Replies (1)

RE: Static binary only - Added by gstrauss almost 5 years ago

I'm having trouble compiling the lighttpd 1.4.53 binary statically, and I don't mean linking modules statically, but linking dependencies statically with lighttpd used by the modules.

Does anyone know how to do this?

Yes. Please search this forum for an answer. Look for the "Search:" box at the upper right of this page. You may have better luck with SCons. Did you read the INSTALL file in the lighttpd source tree?

    (1-1/1)