首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >链接curl库问题eclipse

链接curl库问题eclipse
EN

Stack Overflow用户
提问于 2018-02-11 15:32:07
回答 1查看 704关注 0票数 0

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

我的示例代码是:

代码语言:javascript
运行
复制
#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;
}

错误是:

代码语言:javascript
运行
复制
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

我知道这是我无法解决的链接问题。非常感谢您的帮助,因为我对这个开发环境非常陌生。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-11 18:34:10

因为我找到了这个问题的答案,以防像我这样的人偶然遇到这样的问题。

以下是解决方案

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

我们需要在这里添加curl库的路径:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48729340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档