1

I am developing an application in Linux, which requires static library of curl.Only http and https support is required.I have tried many ways like -Wl,-Bstatic -libcurl , linking to libcurl.a etc. Most alarming is that, I haven't seen anybody who has been successful in doing so, in linux.Only thing I found was in Windows, Linking project with statically build curl

But in linux , almost all answers are like following.

Static linking libcurl using c.

Is it so? Whether it is impossible to make standalone library of curl in linux ?

Following are my build options and results

  1. -Wl,-Bstatic -pthread -lcrypto -Wl,-Bdynamic -ldl -lcurl No error !!!!!
  2. -Wl,-Bstatic -pthread -lcrypto -ldl -lcurl errors ... cannot find -lgcc_s
  3. -static -pthread -lcrypto -ldl -lcurl lot of errors starting with undefined reference "idn_free" 4.-static -pthread -lcrypto -ldl -ldn -lcurl no change.... lot of errors starting with undefined reference "idn_free"
  4. -static /usr/lib/i386-linux-gnu/libpthread.a /usr/lib/i386-linux-gnu/libcrypto.a /usr/lib/i386-linux-gnu/libdl.a /usr/lib/i386-linux-gnu/libidn.a /usr/lib/i386-linux-gnu/libcurl.a no change.... lot of errors starting with undefined reference "idn_free"
Community
  • 1
  • 1
BusyTraveller
  • 183
  • 3
  • 14
  • Following are my build options and results 1. -Wl,-Bstatic -pthread -lcrypto -Wl,-Bdynamic -ldl -lcurl No error !!!!! 2. -Wl,-Bstatic -pthread -lcrypto -ldl -lcurl errors ...cannot find -lgcc_s 3. -static -pthread -lcrypto -ldl -lcurl lot of errors starting with undefined reference "idn_free" – BusyTraveller Feb 08 '17 at 00:06
  • continued.....4. -static -pthread -lcrypto -ldl -ldn -lcurl no change.... lot of errors starting with undefined reference "idn_free" 5. -static /usr/lib/i386-linux-gnu/libpthread.a /usr/lib/i386-linux-gnu/libcrypto.a /usr/lib/i386-linux-gnu/libdl.a /usr/lib/i386-linux-gnu/libidn.a /usr/lib/i386-linux-gnu/libcurl.a no change.... lot of errors starting with undefined reference "idn_free" – BusyTraveller Feb 08 '17 at 00:10
  • @DanielStenberg I have edited the question by adding my build results.My requirement is to have a completely standalone application in linux. – BusyTraveller Feb 08 '17 at 04:58
  • 1
    `idn_free` comes from libidn (which is replaced by libidn2 in current curl) – Daniel Stenberg Feb 08 '17 at 08:33
  • @DanielStenberg From your response , I am assuming that it is possible to have static linking with libcurl.That itself is a big relief. The idn_free is one of the errors. One such error is undefined reference to `X509_get_subject_name. Actually the undefined references are happening in functions such as ossl_send,X509V3_ext, cert_verify_callback, X509_name_oneline, fix_hostname, servercert etc – BusyTraveller Feb 08 '17 at 09:16
  • 1
    You need to keep adding the missing libs to the link line. `X509_*` comes from openssl. – Daniel Stenberg Feb 08 '17 at 09:50
  • Adding /usr/lib/i386-linux-gnu/libgnutls-openssl.a didn't help.I will try with the latest version of openssl. – BusyTraveller Feb 08 '17 at 10:36
  • That doesn't look at all correct. it would be libcrypto.a or libssl.a, and it should probably be the same version your curl was built against to be safe – Daniel Stenberg Feb 08 '17 at 10:37
  • -static /usr/lib/i386-linux-gnu/libpthread.a /usr/lib/i386-linux-gnu/libcrypto.a /usr/lib/i386-linux-gnu/libdl.a /usr/lib/i386-linux-gnu/libidn.a /usr/lib/i386-linux-gnu/libssl.a /usr/lib/i386-linux-gnu/libcurl.a, libcrpto.a was already there.Now I have added libssl.a as well. But the same errors. Am I missing something here ?. – BusyTraveller Feb 08 '17 at 10:54
  • @BusyTraveller did you ever figure anything out? – Vladimir_314159 Jun 05 '18 at 21:45

0 Answers0