Archive for February, 2007

Compiling libcurl with Cygwin for MinGW

Cygwin is my preferred development environment for C/C++ programs at the moment, but I don’t want to create executables or libraries which depend on cygwin1.dll, forcing me to release my programs under the GPL and requiring distribution of an extra DLL. To compile libcurl without Cygwin dependencies, use the following configure line:

./configure \ --build=mingw32 \ CPPFLAGS="-mno-cygwin" \ LDFLAGS="-mno-cygwin"

I’m also a stickler for only building exactly what you need, and since I plan on using libcurl for static linking, I want the library to be as small as possible. Here are my configuration options for generating a small library:

./configure \ --disable-ftp \ --disable-file \ --disable-ldap \ --disable-dict \ --disable-telnet \ --disable-tftp \ --disable-manual \ --disable-ares \ --disable-verbose \ --disable-sspi \ --disable-debug \ --disable-crypto-auth \ --disable-cookies \ --without-ssl \ --without-libssh2 \ LDFLAGS="-Os -s"

One drawback to this approach is having to manually edit the resulting curl-config script to remove -Os -s so it doesn’t forcefully optimize a project depending on libcurl.

Note that neither of these compile lines will work in the standard Windows command-prompt without removing the backslashes and new-lines. If you combine the two options, that makes:

./configure \ --build=mingw32 \ --disable-ftp \ --disable-file \ --disable-ldap \ --disable-dict \ --disable-telnet \ --disable-tftp \ --disable-manual \ --disable-ares \ --disable-verbose \ --disable-sspi \ --disable-debug \ --disable-crypto-auth \ --disable-cookies \ --without-ssl \ --without-libssh2 \ CPPFLAGS="-mno-cygwin" \ LDFLAGS="-mno-cygwin -Os -s"

That results in a 12.6 MB library suitable for static linking and without dependencies on Cygwin. Unfortunately, that seems rather large, considering a 90 KB library can be created according to the “Reducing Size” section of the curl install guide.

Comments