cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Static Lib Size

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 3 Jan 2008 22:39:34 -0800

On Fri, Jan 04, 2008 at 12:50:34AM -0500, Patrick wrote:
> I manually built the curl libraries. I'm using mingw, and can't run
> configure, and therefore can't call it with --disable-* and
> --without-*. So I edited the lib/Makefile.m32 file, and added a bunch
> of "-DCURL_DISABLE_*"s to the CFLAGS. This helped quite a bit,
> knocking the static library size down to about 157KB. However, it's
> still nowhere near the 96KB the install guide mentioned. Here are my
> CFLAGS (I'm probably not doing this right...):

That figure is definitely best-case, but there are a few factors that
could affect the size in your case. For one, the version of mingw you are
using might not produce as efficient code as the one used as the reference.
For another, you are comparing the size of a static library .a file with
the size of a dynamic .so file; the static library file has a lot more
overhead that will increase the size. It also includes all the little
nearly empty object files for disabled features. Once you link the static
library to your application, all that overhead goes away.

> -Os -s -fomit-frame-pointer -DCURL_STATICLIB -DBUILDING_LIBCURL
> -DCURL_DISABLE_LDAPS -DCURL_DISABLE_COOKIES -DCURL_DISABLE_ARES
> -DCURL_DISABLE_CRYPTO_AUTH -DCURL_DISABLE_TFTP -DCURL_DISABLE_TELNET
> -DCURL_DISABLE_DICT -DCURL_DISABLE_LDAP -DCURL_DISABLE_HTTP
> -DCURL_DISABLE_FILE

You should also add the macros to disable IPv6 support and especially
disable verbose error strings (that one will make big difference). Double
check this, but it looks like that equates to undefining ENABLE_IPV6 and
defining CURL_DISABLE_VERBOSE_STRINGS.

> All I really need is FTP support. When I run "make -f Makefile.m32", I
> noticed that file.c, http.c, etc are still compiling and therefore
> being used in libcurl.a. How can I prevent this? I'm very used to *nix
> where I can just run ./configure, so I need a bit of guideance.

Most files are compiled regardless of whether those features are enabled
or not. Sometimes, stubs are compiled in the place of actual functions,
and sometimes there's a big #ifndef CURL_DISABLE_XXX at the beginning of
the file.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-01-04