I've been trying to use LibCURL in C++ for a couple hours now, and it is really getting on my nerves. I have a feeling someone else has had a problem like this before, but I haven't found and posts that have given me a solution.
This is what I've done:
Since the libCurl download page is so confusing, I am posting exactly what I've done. First, I downloaded the file at the top (curl-7.23.1.zip), and then opened it in winRAR. I then went into the include folder, and then extracted the 'curl' folder out of there.
I then created a new project with Code::Blocks, and then moved the 'curl' folder into the same folder as my project.
I then add '#include "curl/curl.h"' to the top of my file, and then try and initialize a simple CURL var... I then get an error, saying:
...\main.cpp|22|undefined reference to `_imp__curl_easy_init'|
Here is a picture of the actual code/error:
Honestly, I think it is something very very stupid that I am doing, but I just don't know what to do.
C API. libcurl is a library of functions that are provided with a C API, for applications written in C. You can easily use it from C++ too, with only a few considerations (see libcurl for C++ programmers).
libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, HTTP/3, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling and more!
How to download a file with curl command. The basic syntax: Grab file with curl run: $ curl https://your-domain/file.pdf. Get file using ftp or sftp protocol: $ curl ftp://ftp-your-domain-name/file.tar.gz.
Description. This function must be the first function to call, and it returns a CURL easy handle that you must use as input to other functions in the easy interface. This call MUST have a corresponding call to curl_easy_cleanup when the operation is complete.
Finally got it to work with some of help
Here is how I did it:
To use libCurl with Qt, it is a bit easier.
Move all necessary files/dlls/libraries into your debug folder. Make sure that you include the 'curl' folder.
Go to your .pro file, and add the location of the 'libcurldll.a' file. For example(mine):
LIBS += C:\libcurl\7.24.0\lib\libcurldll.a
Enjoy.
Thanks R. Martinho Fernandes!
You must also include the lib/
folder from libcurl, which contains *.a
or *.dll
files. Theses files are the library itself, the compiled binary on which you link your program.
If you link the library dynamically, you'll need to put the *.dll
in your project directory, in C:\Windows
or in C:\MinGW\bin
(if C:\MinGW is the compiler path).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With