连接curl库问题eclipse

Linking curl library problems eclipse

我正在尝试在 eclipse 中开发时使用 curl。但是我对 C++ 开发的 Eclipse 很陌生。链接库时我遇到以下问题。非常感谢与此相关的任何帮助。

我的示例代码是:

#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;
}

错误是:

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)

我尝试了很多网上的解决方案。但我不知道我哪里做错了。一些解决方案是:

Curl linking problem

makefile problems

Make file problem

Makefile:146: recipe for target 'all' failed #28

usr/bin/ld: cannot find -l

我知道这是我无法解决的链接问题。非常感谢任何帮助,因为我是这个开发环境的新手

因为我找到了问题的答案,以防万一像我这样的人偶然发现此类问题。

这是解决方案

Project>>Properties>>C/C++ Build >> Settings >> Tool Settings >> GCC C++ Linker

我们需要在此处添加 curl 库的路径: