cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: libcurl as static library

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 17 Sep 2010 08:44:36 -0700

On Fri, Sep 17, 2010 at 08:50:52AM +0200, Cristina Gil wrote:
> Thanks Dan for your quick reply.
>
> usuario_at_linux-dt3x:~/proyectos/scs_h264/src> curl-config --static-libs
> /usr/local/lib/libcurl.a -lidn -lssl -lcrypto -lldap -lrt -lssl -lcrypto
> -ldl -lz -lz

There it is-- -lidn. But for some reason it's not being picked up.

> On Fri, Sep 17, 2010 at 08:21:39AM +0200, Cristina Gil wrote:
> > I wanna compile my program in static mode (it works fine in dynamic), I
> > re-compiled libcurl with (To force a static library compile, disable the
> > shared library creation by running configure like:
> > ./configure --disable-shared)
> >
> > Then set: curl-config --static-libs

What do you mean "Then set"?

> > Compile mi program: g++ -static *.cpp -o scs_H264 -pthread -lcurl

Your program must be linked with the arguments that "curl-config
--static-libs" provides. So this line should look like this instead:

g++ -static *.cpp -o scs_H264 -pthread -lcurl `curl-config --static-libs`

But since you have -static in there, you have to make sure that there are
static versions of all dependent libraries available. And you'll have
to do the `curl-config --static-libs` trick (or equivalent) with all
those dependent libraries, including libcurl's, and all THEIR dependent
libraries as well. `curl-config --static-libs` on its own is designed to
link apps with a static libcurl but dynamic everything else.

This will be a lot easier if you disable all the protocols you don't need
when you build libcurl, to reduce those dependencies. If you don't need
IDNA, SSL, LDAP and ZLIB support, then disable them and save yourself
some hassle.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-17