添加卷曲库C

Add curl library C++

本文关键字:添加      更新时间:2023-10-16

我在编码方面并不新鲜。我想将libcurl库添加到我的Visual Studio项目中,我想我做对了,但我不确定。我遇到的任何错误都缺少

#include <curl/curl.h>
#include <libxml/HTMLparser.h>

我添加了带有参考的库 ->管理nuget packages->和libcurl.net库

但我仍然有编译错误。我也有警告,也许问题是从

警告
Severity    Code    Description Project File    Line    Suppression State
Warning     The 'packages' element is not declared. Project3    C:UsersPcDocumentsVisual Studio 2015ProjectsProject3Project3packages.config 2   

这是我的某个代码的一部分

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <curl/curl.h>
#include <libxml/HTMLparser.h>
//
//  Case-insensitive string comparison
//
#ifdef _MSC_VER
#define COMPARE(a, b) (!_stricmp((a), (b)))
#else
#define COMPARE(a, b) (!strcasecmp((a), (b)))
#endif
//
//  libxml callback context structure
//
struct Context
{
    Context() : addTitle(false) { }
    bool addTitle;
    std::string title;
};
//
//  libcurl variables for error strings and returned data
static char errorBuffer[CURL_ERROR_SIZE];
static std::string buffer;

我也发现了许多相同的主题,并且阅读良好,但我不知道我的问题在哪里。

也是一个问题,我的目标是从在线页面上获取一个简单的字符串!您知道获取字符串的更好,更简单的方法吗?

您应该为编译器的libcurl标头文件提供路径(在Project->Properties->C/C++->General->Additional Include Directories处开处方(和libcurl.lib(与libcurl.dll配对(linker(libcurl.dll(在Project->Properties->Linker->Input->Additional Dependencies处开处方(。