Static libcurl binding using c

I use Libcurl in my application with the C and GNU compiler on a Linux machine. The application also uses OpenSSL libraries and some other libraries. I am trying to statically link libraries, with the exception of lcurl links to other libraries work just fine.

I am trying to compile as below.

 gcc -static -I. -o test test.c -lz -lssl -lcrypto -lcurl 

Am I doing something wrong? Is there a way to force static links of some librairies (libc for example)?

+4
source share
1 answer

Libcurl itself is linked to tons of other libraries, most of which are not included in your compilation command line. For example, my (on Debian Squeeze) links to:

  • Libc
  • libcom_err
  • libcrypto
  • libdl
  • libgcrypt
  • libgnutls
  • libgpg error
  • libgssapi_krb5
  • libidn
  • libk5crypto
  • libkeyutils
  • libkrb5
  • libkrb5support
  • liblber-2,4
  • libldap_r-2,4
  • libpthread
  • libresolv
  • librt
  • libsasl2
  • libssh2
  • libssl
  • libtasn1
  • libz

(You can get a similar list for yourself by running ldd in the Linux library or otool -L in Darwin.)

+3
source

All Articles