Compiling with libcurl

6 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 4 months 3 days ago
Joined: 2009-05-03 16:54
Compiling with libcurl

Hello guys,
I am implementing an app where currently I am using sockets to get data from urls. It works fine but I thought that using libCurl might be a better, faster solution. So I downloaded the libCurl from os4depot and installed it using the autoinstall script.

For a test tried to compile the a simple code found at
https://raw.githubusercontent.com/curl/curl/master/docs/examples/simple.c

I use the following to compile it
gcc -D__USE_INLINE__ -Wall simple.c -o simple -lcurl -lauto

but I am getting a lot of undefined references like below.

  1. openssl.c:(.text+0x4804): undefined reference to `EVP_PKEY_get0_DSA'
  2. openssl.c:(.text+0x4818): undefined reference to `DSA_get0_pqg'
  3. openssl.c:(.text+0x482c): undefined reference to `DSA_get0_key'
  4. openssl.c:(.text+0x48bc): undefined reference to `EVP_PKEY_get0_DH'
  5. openssl.c:(.text+0x48d0): undefined reference to `DH_get0_pqg'
  6. openssl.c:(.text+0x48e4): undefined reference to `DH_get0_key'
  7. openssl.c:(.text+0x4944): undefined reference to `OCSP_BASICRESP_free'
  8. openssl.c:(.text+0x4950): undefined reference to `OCSP_RESPONSE_free'
  9. openssl.c:(.text+0x498c): undefined reference to `OCSP_crl_reason_str'
  10. openssl.c:(.text+0x4a1c): undefined reference to `OCSP_RESPONSE_free'
  11. openssl.c:(.text+0x4a90): undefined reference to `X509_NAME_get_entry'
  12. openssl.c:(.text+0x4a94): undefined reference to `X509_NAME_ENTRY_get_data'
  13. openssl.c:(.text+0x4aa0): undefined reference to `ASN1_STRING_type'
  14. openssl.c:(.text+0x4ab4): undefined reference to `ASN1_STRING_to_UTF8'
  15. openssl.c:(.text+0x4b04): undefined reference to `X509_verify_cert_error_string'
  16. openssl.c:(.text+0x4b2c): undefined reference to `OCSP_response_status_str'
  17. openssl.c:(.text+0x4b84): undefined reference to `BIO_free'
  18. openssl.c:(.text+0x4b94): undefined reference to `X509_free'
  19. openssl.c:(.text+0x4c2c): undefined reference to `BIO_free'
  20. openssl.c:(.text+0x4c34): undefined reference to `X509_free'
  21. openssl.c:(.text+0x4d18): undefined reference to `BIO_free'
  22. openssl.c:(.text+0x4d20): undefined reference to `X509_free'
  23. openssl.c:(.text+0x4d5c): undefined reference to `GENERAL_NAMES_free'

I guess I am missing something that has to do with AmiSSL, which is also installed in my SDK.
Can you guys point me to the right direction?
Thank you for your help.

walkero
walkero's picture
Offline
Last seen: 4 months 3 days ago
Joined: 2009-05-03 16:54
Re: Compiling with libcurl

Tried to compile it by adding at the end
-mcrt=clib2

and now I get the following errors only

  1. In file included from /SDK/local/common/include/curl/curl.h:2851,
  2. from simple.c:29:
  3. /SDK/local/common/include/curl/multi.h:157:40: error: unknown type name 'fd_set'; did you mean 'sk_set'?
  4. fd_set *read_fd_set,
  5. ^~~~~~
  6. sk_set
  7. /SDK/local/common/include/curl/multi.h:158:40: error: unknown type name 'fd_set'; did you mean 'sk_set'?
  8. fd_set *write_fd_set,
  9. ^~~~~~
  10. sk_set
  11. /SDK/local/common/include/curl/multi.h:159:40: error: unknown type name 'fd_set'; did you mean 'sk_set'?
  12. fd_set *exc_fd_set,
  13. ^~~~~~
  14. sk_set

Any idea?

Update:

Added in the code the following, which solde the fd_set problem
#include <sys/select.h>

But then I got the following error
gcc/ppc-amigaos/bin/ld: cannot find -lauto

I checked the clib2/lib folder and there is no libauto.a file in there. So the error make sense.
What confuses me is that if I remove it, I get again all the undefined references I was getting earlier.

salass00
salass00's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 11:27
Re: Compiling with libcurl

It is because libcurl depends on other libs.

Looking at the libcurl.la file in the archive on os4depot the following should work to link with libcurl "-lcurl -lrtmp -lssl -lcrypto -lz". The ssl and crypto libraries are from libopenssl and rtmp from librtmp.

walkero
walkero's picture
Offline
Last seen: 4 months 3 days ago
Joined: 2009-05-03 16:54
Re: Compiling with libcurl

@salass00
Thank you so much for your comment.
At the end I needed to download libz and compile with the following
gcc -D__USE_INLINE__ -Wall simple.c -o simple -lcurl -lrtmp -lssl -lcrypto -lz -lpthread

Thanks again. Now I can evaluate if it is best to access the various urls I need using socket or use the libcurl, to make my life easier. What would you follow guys?

kas1e
kas1e's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-11-30 15:30
Re: Compiling with libcurl

What would you follow guys

libcurl if you do not much worry about size (and use my one from Odyssey SDK, as it latest one and contains some good fixes in terms of threading resolver). And if you need some tiny/small/cool app, then pure socket programming (which is _much_ harder compare with culr usage)

walkero
walkero's picture
Offline
Last seen: 4 months 3 days ago
Joined: 2009-05-03 16:54
Re: Compiling with libcurl

Thanks Roman for your recommendation.
It would be great if you could release that newer libcurl in a package on OS4Depot, so that everyone can find and use it.

Log in or register to post comments