I am trying to use curl while developing in eclipse. However i am very new to eclipse for c++ development. While linking libraries i am having the following problems. Any help related to this is really appreciated.
My sample code is :
#include <iostream>
#include <string>
#include <curl/curl.h>
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int main(void)
{
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
std::cout << readBuffer << std::endl;
}
return 0;
}
ERROR IS:
12:37:29 **** Incremental Build of configuration Debug for project Bestapi ****
make all
Building target: Bestapi
Invoking: GCC C++ Linker
g++ -L/usr/include -o "Bestapi" ./bestapi.o -l/usr/include
/usr/bin/ld: cannot find -l/usr/include
collect2: error: ld returned 1 exit status
makefile:44: recipe for target 'Bestapi' failed
make: *** [Bestapi] Error 1
12:37:30 Build Finished (took 366ms)
I have tried many solutions available on the internet. But i dont know where i am doing wrong. Some of the solutions are :
Makefile:146: recipe for target 'all' failed #28
I know this is linking problem which i am unable to solve. Any help is really appreciated as i am very new to this development environment