添加curl库C ++ [英] Add curl library C++

查看:82
本文介绍了添加curl库C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编码方面并不陌生.我想将libcurl库添加到我的Visual Studio项目中,我认为我做对了,但不确定.我怎么在标头丢失

I'm little new in coding. I want to add libcurl library to my visual studio project , I think I do it right but I'm not sure . how ever I have some errors in header missing

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

我添加了带有References-> Manage Nuget包->和libcurl.net库的库

I add the library with References->Manage Nuget packages->and libcurl.net library

但是我在编译时仍然有错误.我也有警告,也许问题出在

but still I have errors on compile. also I have a warning too maybe problem is in warning from

Severity    Code    Description Project File    Line    Suppression State
Warning     The 'packages' element is not declared. Project3    C:\Users\Pc\Documents\Visual Studio 2015\Projects\Project3\Project3\packages.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;

我也找到了很多相同的主题,并且都读得很好,但是我不知道我的问题在哪里.

also I find many same topics and read them well but I don't know where is my problem.

还有另一个问题,我的目标是从在线页面获得一个简单的字符串!您知道一种更好,更轻松的方法来获取字符串吗?

also for an another question , my goal is get an simple string from an online page ! do you know a better and easier way to get an string??

推荐答案

您应为编译器提供 libcurl 头文件的路径(在 Project-> Properties中指定该路径)-> C/C ++->常规->其他包含目录),并链接到libcurl.lib(与libcurl.dll配对)(在 Project->中指定它).属性->链接器->输入->其他依赖项).

You should provide the path to the header files of libcurl for the compiler (prescribe it at Project->Properties->C/C++->General->Additional Include Directories) and to the libcurl.lib (it is paired with libcurl.dll) for the linker (prescribe it at Project->Properties->Linker->Input->Additional Dependencies).

这篇关于添加curl库C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆