cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl-7.29.0: 'curl' executable fails to link against custom-built OpenSSL

From: Jeroen De Ridder <voetsjoeba+curl_at_gmail.com>
Date: Mon, 4 Mar 2013 16:34:48 +0100

I'm currently building curl-7.29.0 from source on a RHEL 5 64-bit
machine against a custom-compiled version of OpenSSL 1.0.0j that's
installed in /home/ct-dist/myopenssl. There is also an old system
library of OpenSSL on my machine, with sonames libssl.so.6 and
libcrypto.so.6 (as opposed to libssl.so.1.0.0 and libcrypto.so.1.0.0
of the new installation). For now, I'm only doing a shared library
build, and I want to build it against the OpenSSL 1.0.0j installation.
The build goes OK and successfully creates libcurl.so with the correct
dependencies on the new OpenSSL libraries, but the final stage where
it has to link the 'curl' executable fails with the following error
(snipped a bit for brevity):

/bin/sh ../libtool --tag=CC --mode=link gcc -g -O0
-Wno-system-headers -L/home/ct-dist/myopenssl/lib -o curl
curl-tool_binmode.o [..snip..] curl-nonblock.o ../lib/libcurl.la -lz
-lrt

libtool: link: gcc -g -O0 -Wno-system-headers -o .libs/curl
curl-tool_binmode.o [..snip..] curl-nonblock.o
-L/home/ct-dist/myopenssl/lib ../lib/.libs/libcurl.so -lz -lrt
-Wl,-rpath -Wl,/home/ct-dist/mycurl/lib
/usr/bin/ld: warning: libssl.so.1.0.0, needed by
../lib/.libs/libcurl.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcrypto.so.1.0.0, needed by
../lib/.libs/libcurl.so, not found (try using -rpath or -rpath-link)
../lib/.libs/libcurl.so: undefined reference to `SSL_connect'
../lib/.libs/libcurl.so: undefined reference to `X509_check_issued'
(etc).

Notice that the command line does not specify -lssl and -lcrypto,
although it looks like they should be in there. Indeed, when I add
these back in, the link completes nicely without any further
complaints.
Looking at src/Makefile, it appears that the rule that performs this
link is the following:

curl$(EXEEXT): $(curl_OBJECTS) $(curl_DEPENDENCIES) $(EXTRA_curl_DEPENDENCIES)
    @rm -f curl$(EXEEXT)
    $(curl_LINK) $(curl_OBJECTS) $(curl_LDADD) $(LIBS)

Printing out these variables shows the following:
    curl_LDADD = ../lib/libcurl.la -lz -lrt
    curl_LIBS =

And the definition of curl_LDADD higher up shows the following:

curl_LDADD = $(top_builddir)/lib/libcurl.la -lz -lrt
#curl_LDADD = $(top_builddir)/lib/libcurl.la -lidn -lssl -lcrypto
-lssl -lcrypto -lz -lrt

So evidently at one point the -lssl -lcrypto flags were there, but
they were commented out and removed. What happened? How come they
aren't in there anymore?

For reference:
Per ./configure --help's suggestion, I'm using pkg-config to tell curl
about the location of my custom-built OpenSSL libraries by editing the
PKG_CONFIG_PATH environment variable. This seems to work well, given
the fact that everything but the final curl executable compiles and
links fine. Here's my build script:

export PKG_CONFIG_PATH="/home/ct-dist/myopenssl/lib/pkgconfig:$PKG_CONFIG_PATH"
CONFIGURE="./configure --prefix=/home/ct-dist/mycurl \
                       --disable-maintainer-mode \
                       --enable-debug \
                       --disable-static \
                       --disable-optimize \
                       --disable-warnings \
                       --disable-werror \
                       --disable-ldap \
                       --disable-ldaps \
                       --without-polarssl \
                       --without-cyassl \
                       --without-gnutls \
                       --without-nss \
                       --without-axtls \
                       --without-libssh2 \
                       --without-winidn"

make clean
$CONFIGURE && make && make install

Thanks,
-- Jeroen
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-04