Haxx ad

curl's project page on


cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: reducing the libcurl footprint

From: Dan Fandrich <>
Date: Mon, 24 Sep 2007 21:58:14 -0700

On Mon, Sep 24, 2007 at 05:18:32PM -0700, Ganesh Ragavan wrote:
> We are using libcurl for one of our embedded applications in a PowerPC
> architecture. We are using libcurl for HTTP alone. I am trying to reduce the
> footprint of the library. I used the following configure options:
> ./configure --target=powerpc-hardhat-linux --host=powerpc-hardhat-linux --build
> =i586-pc-linux-gnu --with-random=/dev/urandom --disable-ftp --disable-ldap
> --disable-dict --disable-telnet --disable-tftp --disable-verbose
> --disable-debug --disable-manual --disable-sspi --disable-thread --disable-ares
> --disable-cookies --disable-gopher --disable-file --disable-crypto-auth
> --disable-ipv6 --enable-hidden-symbols --without-ssl --without-libidn
> --without-zlib --without-libssh2 --without-gnutls --without-nss
> --without-ca-bundle --without-libidn --without-strerror
> With the above options and stripping, I can get a library of size 153 KB. But
> I cannot afford a size of more than 100 KB. The man page for install says that
> I could get a size as small as 90KB.

That figure was for the x86 architecture which is more compact than PowerPC,
and it was also for libcurl as of seven releases ago; much has been added
since then. I just followed the instructions in INSTALL with the CVS version
(post-7.17.0) using gcc 4.2.2 and the figure I get is now 98 KiB.

Still, you're missing some of the suggestions mentioned in INSTALL. Try
adding to your configure line:
  CFLAGS='-Os' LDFLAGS='-Wl,-Bsymbolic -Wl,-s'
to make gcc make size saving optimizations, and have the linker strip
symbols from your shared library.

> Also I was looking into the mailing
> thread at
> I do not know how to implement the optimizations mentioned in the thread.
> Could someone please explain me with syntax how I could include the following
> optimizations mentioned in the thread?
> "Since you only want http, the supplied getdate.y is overkill and could be
> greatly dumbed down, saving 10 KB"

This optimization is already found in the standard curl sources.

> "By preventing the linking of various unneeded stub files into the shared
> library, you could save couple KB"

You'll have to manually edit your make files to remove references to "empty"
files like telnet.o and krb4.o so the linker doesn't even try to link them.
You'll probably see the same savings by using an appropriate strip command
on the linker or objcopy.

> "If you don't need HTTP digest authentication, you could add some #ifdefs in
> the code and add a --without-digest configure option and safe another 8 KB"

This has already been added with the option --disable-crypto-auth

> "If you don't need verbose error strings, you could add a --without-strerror
> and save another 6 KB"

This has already been added with the option --disable-verbose

> Also please let me know of other suggestions that could bring down my size.

Also mentioned in the INSTALL file is to statically link your app,
avoiding the shared library overhead and any unneeded functions.
The final suggestion in the INSTALL file is to use the -R option of
objcopy on the library and remove any unneeded sections (like .comment).
That means a command like:

objcopy -R .comment --strip-unneeded lib/ smaller/

If you aren't already using gcc ver. 4.x, then doing so will enable
--enable-hidden-symbols and save a bit more space, and will probably
give smaller code simply by being on the cutting edge.

There are more things you could remove from the code if you really wanted
to get your hands dirty, but the payoff will quickly deteriorate. A
quick thing to save a few KB would be to compile away failf() in the same
way as infof().

>>> Dan

--              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-09-25

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET