cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Static libcurl with static libcurl dependencies

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 20 Apr 2012 15:12:57 +0200

On Fri, Apr 20, 2012 at 02:34:28PM +0200, molator molator wrote:
> I'm trying to build statically libcurl with static dependencies from source on
> Ubuntu 8.04 (not negotiable).
> So far i can build:
> - shared libcurl with shared dependencies,
> - static libcurl with shared dependencies.
>
> But no success for static libcurl with static dependencies.

That's not something the libcurl configure scripts support in the general
case. However, it should work if all the dependent libaries are available
*only* as static libraries, and all their pkg-config files are correctly
configured for those static libraries. And, of course, it should also
work in the case where all the features dependent on external libraries
are turned off with --disable-* and the -static flag is passed to the linker
with LDFLAGS.

> For CMake, i'm using:
> cmake .. -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DCURL_DISABLE_LDAP=ON
>
> For configure:
> ./configure --disable-shared --enable-static --disable-ldap --disable-ldaps
>
> CMake settings doesn't allow it, so i played with configure/Makefile settings:
> -static -lidn -lssl -lcrypto -lldap -lrt -ldl -lz

It looks like you're interested in linking against OpenSSL
statically. There's a section in the INSTALL file about that special
case.

> Everytime i think it's fine, ldd shows me references to the shared
> dependencies.
> In the other hand, i get a bunch of error "undefine reference to" and such.
>
> Is there anything else i can try ?

The easiest way is probably going to be to build libcurl normally, then look
at the link command that's executed at the end and run it manually with
tweaks to explicitly point to the static versions of the dependent
libraries (and their dependencies, in turn).

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-20