Some OpenSSL configure tests not linking OpenSSL #2199

Closed
MarcelRaad opened this Issue Dec 28, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@MarcelRaad
Member

MarcelRaad commented Dec 28, 2017

I did this

./configure --enable-warnings --enable-werror --enable-static --disable-shared [...] --with-ssl="/[...]/openssl/[...]"

OpenSSL's lib directory only contains libcrypto.a and libssl.a.

From config.log (https://github.com/curl/curl/blob/curl-7_57_0/configure.ac#L1638):

configure:22599: checking for HMAC_Update in -lcrypto
configure:22621: gcc -o conftest [...]  -I/[...]/openssl/[...]/include -I/[...]/openssl/[...]/include/openssl  -L/[...]/openssl/[...]/lib conftest.c -lcrypto   >&5
conftest.c:51:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
char HMAC_Update ();
^
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x25): undefined reference to `pthread_rwlock_init'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0x65): undefined reference to `pthread_rwlock_rdlock'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0x85): undefined reference to `pthread_rwlock_wrlock'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0xa5): undefined reference to `pthread_rwlock_unlock'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0xca): undefined reference to `pthread_rwlock_destroy'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0xf5): undefined reference to `pthread_once'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0x115): undefined reference to `pthread_key_create'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0x147): undefined reference to `pthread_setspecific'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0x167): undefined reference to `pthread_key_delete'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0x133): undefined reference to `pthread_getspecific'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x1a4): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x262): undefined reference to `dlerror'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x2c9): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x339): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x372): undefined reference to `dlerror'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x421): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x489): undefined reference to `dlerror'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x652): undefined reference to `dlclose'
configure:22641: checking for HMAC_Init_ex in -lcrypto
configure:22663: gcc -o conftest [...]  -I/[...]/openssl/[...]/include/openssl -I/[...]/openssl/[...]/include  -L/[...]/openssl/[...]/lib conftest.c -lcrypto   >&5
conftest.c:51:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
char HMAC_Init_ex ();
^
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x25): undefined reference to `pthread_rwlock_init'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0x65): undefined reference to `pthread_rwlock_rdlock'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0x85): undefined reference to `pthread_rwlock_wrlock'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0xa5): undefined reference to `pthread_rwlock_unlock'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0xca): undefined reference to `pthread_rwlock_destroy'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0xf5): undefined reference to `pthread_once'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0x115): undefined reference to `pthread_key_create'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0x147): undefined reference to `pthread_setspecific'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0x167): undefined reference to `pthread_key_delete'
/[...]/openssl/[...]/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0x133): undefined reference to `pthread_getspecific'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x1a4): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x262): undefined reference to `dlerror'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x2c9): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x339): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x372): undefined reference to `dlerror'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x421): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x489): undefined reference to `dlerror'
/[...]/openssl/[...]/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x652): undefined reference to `dlclose'
configure:22681: checking OpenSSL linking with -ldl
configure:22698: gcc -o conftest [...]  -I/[...]/openssl/[...]/include/openssl -I/[...]/openssl/[...]/include  -L/[...]/openssl/[...]/lib conftest.c -ldl  >&5
/tmp/ccxJxgSF.o: In function `main':
conftest.c:(.text.startup+0x5): undefined reference to `ERR_clear_error'
configure:22709: checking OpenSSL linking with -ldl and -lpthread
configure:22726: gcc -o conftest [...]  -I/[...]/openssl/[...]/include/openssl -I/[...]/openssl/[...]/include  -L/[...]/openssl/[...]/lib conftest.c -lpthread -ldl  >&5
/tmp/cco8FOvK.o: In function `main':
conftest.c:(.text.startup+0x5): undefined reference to `ERR_clear_error'

I expected the following

-lcrypto also being passed to the -ldl and -ldl -lpthread tests

curl/libcurl version

7.57.0 (OpenSSL 1.1.0g)

operating system

Ubuntu 16.04 Xenial

@jay

This comment has been minimized.

Show comment
Hide comment
@jay

jay Jan 12, 2018

Member

@MarcelRaad please see if #2234 fixes your issue

Member

jay commented Jan 12, 2018

@MarcelRaad please see if #2234 fixes your issue

@MarcelRaad

This comment has been minimized.

Show comment
Hide comment
@MarcelRaad

MarcelRaad Jan 13, 2018

Member

It doesn't fix the main issue here, but it fixes the build for me if I manually delete the lines removing -lcrypto again in the resulting makefile.

Member

MarcelRaad commented Jan 13, 2018

It doesn't fix the main issue here, but it fixes the build for me if I manually delete the lines removing -lcrypto again in the resulting makefile.

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jun 14, 2018

Member

We typically don't bother very much with static builds, especially not without pkg-config data since it is a futile race trying to make that to work for everyone. In the past LIBS="-ldl" ./configure ... has helped to get it going.

That said, when I install the latest openssl git version static-only, my curl configure script detects and links with that just fine:

checking OpenSSL linking with -ldl... no
checking OpenSSL linking with -ldl and -lpthread... yes
checking for SSL_connect in -lssl... yes

Member

bagder commented Jun 14, 2018

We typically don't bother very much with static builds, especially not without pkg-config data since it is a futile race trying to make that to work for everyone. In the past LIBS="-ldl" ./configure ... has helped to get it going.

That said, when I install the latest openssl git version static-only, my curl configure script detects and links with that just fine:

checking OpenSSL linking with -ldl... no
checking OpenSSL linking with -ldl and -lpthread... yes
checking for SSL_connect in -lssl... yes

@MarcelRaad

This comment has been minimized.

Show comment
Hide comment
@MarcelRaad

MarcelRaad Jun 14, 2018

Member

Static linking without pkg-config works fine with LIBS='-ldl -lpthread' and this is what I'm doing at the moment. However, this check seems to exist for the very reason to make that unnecessary:
c68fed8

My use case is creating a libcurl Conan package referencing an OpenSSL Conan package, so the pkg-config generated by OpenSSL is not really usable, unfortunately.

Member

MarcelRaad commented Jun 14, 2018

Static linking without pkg-config works fine with LIBS='-ldl -lpthread' and this is what I'm doing at the moment. However, this check seems to exist for the very reason to make that unnecessary:
c68fed8

My use case is creating a libcurl Conan package referencing an OpenSSL Conan package, so the pkg-config generated by OpenSSL is not really usable, unfortunately.

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jun 14, 2018

Member

What OpenSSL version are you trying this with?

Member

bagder commented Jun 14, 2018

What OpenSSL version are you trying this with?

@bagder bagder added the SSL/TLS label Jun 14, 2018

@MarcelRaad

This comment has been minimized.

Show comment
Hide comment
@MarcelRaad

MarcelRaad Jun 14, 2018

Member

This was originally OpenSSL 1.1.0g and curl 7.57.0. I just retried with OpenSSL 1.1.0h and curl 7.60.0 and the result is the same:

configure: PKG_CONFIG_LIBDIR will be set to "[...]/lib/pkgconfig"
checking for HMAC_Update in -lcrypto... no
checking for HMAC_Init_ex in -lcrypto... no
checking OpenSSL linking with -ldl... no
checking OpenSSL linking with -ldl and -lpthread... no
checking for ssl_version in -laxtls... no
configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.
configure: WARNING: Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-axtls, --with-winssl, or --with-darwinssl to address this.
Member

MarcelRaad commented Jun 14, 2018

This was originally OpenSSL 1.1.0g and curl 7.57.0. I just retried with OpenSSL 1.1.0h and curl 7.60.0 and the result is the same:

configure: PKG_CONFIG_LIBDIR will be set to "[...]/lib/pkgconfig"
checking for HMAC_Update in -lcrypto... no
checking for HMAC_Init_ex in -lcrypto... no
checking OpenSSL linking with -ldl... no
checking OpenSSL linking with -ldl and -lpthread... no
checking for ssl_version in -laxtls... no
configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.
configure: WARNING: Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-axtls, --with-winssl, or --with-darwinssl to address this.

bagder added a commit that referenced this issue Jun 14, 2018

configure: enhance ability to detect/build with static openssl
Fix the -ldl and -ldl + -lpthread checks for OpenSSL, necessary for
building with static libs without pkg-config.

Reported-by: Marcel Raad
Fixes #2199
@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jun 14, 2018

Member

I could reproduce the issue using 1.1.0h and with the fix from #2659 it then subsequently works!

Member

bagder commented Jun 14, 2018

I could reproduce the issue using 1.1.0h and with the fix from #2659 it then subsequently works!

@MarcelRaad

This comment has been minimized.

Show comment
Hide comment
@MarcelRaad

MarcelRaad Jun 14, 2018

Member

Great, thank you very much! I can confirm it works for me too.

Member

MarcelRaad commented Jun 14, 2018

Great, thank you very much! I can confirm it works for me too.

@bagder bagder closed this in 351dabb Jun 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment