So I downloaded the zip file from the curl website. I copied the directory with all of the header files into my include directory. Including the curl.h works with no problems, however, when I go to actually call a function, suddenly my c++ app will no longer compile.
Here's the error I'm receiving:
[Linker error] undefined reference to
`curl_easy_init'
Here's the code:
#define CURL_STATICLIB
#include <curl/curl.h>
#include <string>
#include <iostream>
using namespace std;
int main() {
string url = "http://www.google.com";
cout << "Retrieving " << url << endl;
// Our curl objects
CURL *curl;
CURLcode result;
// Create our curl handle
curl = curl_easy_init();
system("pause");
return 0;
}
It works fine if I comment out the curl=curl_easy_init() line.
According to the documentation this should work, as seen here.
Any ideas?
you must link your program with the curl library
-L/path/of/curl/lib/libcurl.a (g++)
or add curl in your solution
Solution->properties->Link(ing) and add libcurl.lib
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