views:

350

answers:

1

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?

+4  A: 

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
Nadir SOUALEM
There is no libcurl.a in http://curl.haxx.se/download/curl-7.19.6.zip
Cory Dee
is there a .so?
sean riley
No. There's libcurl.imp, .plist, .rc and .vcproj, but no .a or .so
Cory Dee
have you compiled it ?./configuremakemake installor have you built it with Visual studio ?
Nadir SOUALEM
No, I was under the impression I could include the headers and it would just work from there?
Cory Dee
try to compile it !
Nadir SOUALEM