本文介绍了libcurl编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用libcurl,我得到这些错误,没有写任何代码只是编译,我不知道为什么
Fehler 49错误C2628:'$ UnnamedClass $ 0x05e5b255 $ 395 $'gefolgt von'bool'unzulässig(Semikolon';'vergessen?)c:\users\ttg\desktop\curl- 7.21.7\lib\setup_once。 h 273
Fehler 50错误C2065:'_SH_DENYNO':nichtdeklarierter Bezeichner C:\Program Files(x86)\Microsoft Visual Studio 9.0 \VC\include \xiosbase 111
首先是libcurl文件,它后面跟着bool(forgot semicolon?)
第二个未声明的标识符
这是整个代码
#pragma once
#include< curl / curl.h>
#include< curl / easy.h>
#include< stdio.h>
#include< stdlib.h>
#include< assert.h>
#include< string>
#include< sstream>
#include< iostream>
using namespace std;
命名空间fr {
使用命名空间System;
using namespace System :: ComponentModel;
using namespace System :: Collections;
using namespace System :: Windows :: Forms;
using namespace System :: Data;
using namespace System :: Drawing;
static size_t write_data(void * ptr,size_t size,size_t nmemb,void * stream)
{
// assert(bodyfile ==(FILE *)stream); //这个断言失败,但是当我评论它,代码工作。为什么?
int written = fwrite(ptr,size,nmemb,(FILE *)stream);
return written;
}
///< summary>
/// ZusammenfassungfürForm1
///
/// Warnung:Wenn Sie den Namen dieser Klasseändern,müssenSie auch
/// die Ressourcendateiname-Eigenschaftfürdas Tool zur Kompilierung verwalteter Ressourcenändern,
/// das allen RESX-Dateien zugewiesen ist,von denen diese Klasseabhängt。
/// Anderenfallskönnendie设计师nicht korrekt mit den lokalisierten Ressourcen
/// arbeiten,die diesem Formular zugewiesen sind。
///< / summary>
public ref class Form1:public System :: Windows :: Forms :: Form
{
public:
Form1(void)
{
InitializeComponent );
//
// TODO:Konstruktorcode hierhinzufügen。
//
}
protected:
///< summary>
/// Verwendete Ressourcen bereinigen。
///< / summary>
〜Form1()
{
if(components)
{
删除组件;
}
}
protected:
protected:
private:
///< summary> ;
/// Erforderliche Designervariable。
///< / summary>
System :: ComponentModel :: Container ^ components;
#pragma region Windows窗体设计器生成的代码
///< summary>
/// Erforderliche MethodefürdieDesignerunterstützung。
/// Der Inhalt der Methode darf nicht mit dem Code-Editorgeändertwerden。
///< / summary>
void InitializeComponent(void)
{
this-> SuspendLayout();
//
// Form1
//
this-> AutoScaleDimensions = System :: Drawing :: SizeF(6,13);
this-> AutoScaleMode = System :: Windows :: Forms :: AutoScaleMode :: Font;
this-> ClientSize = System :: Drawing :: Size(284,262);
this-> Name = LForm1;
this-> Text = LForm1;
this-> ResumeLayout(false);
}
#pragma endregion
private:System :: Void backgroundWorker1_DoWork(System :: Object ^ sender,System :: ComponentModel :: DoWorkEventArgs ^ e){
CURL * curl_handle;
const char * headerfilename =head.out;
FILE * headerfile;
const char * bodyfilename =body.html;
FILE * bodyfile;
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle,CURLOPT_URL,http:// url);
curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS,1L);
curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION,write_data);
headerfile = fopen(headerfilename,w);
if(headerfile == NULL){
curl_easy_cleanup(curl_handle);
return;
}
bodyfile = fopen(bodyfilename,w);
if(bodyfile == NULL){
curl_easy_cleanup(curl_handle);
return;
}
curl_easy_setopt(curl_handle,CURLOPT_WRITEHEADER,headerfile);
curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA,bodyfile);
curl_easy_perform(curl_handle);
fclose(headerfile);
fclose(bodyfile);
curl_easy_cleanup(curl_handle);
}
};
}
这是第二个问题的解释:
1> C:\Program Files(x86)\ Microsoft Visual Studio 9.0 \VC\include\xiosbase(111):error C2065:'_SH_DENYNO ':nichtdeklarierter Bezeichner
1> C:\Program Files(x86)\Microsoft Visual Studio 9.0 \VC\include\xiosbase(196):Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-templatestd :: _ Iosb< _Dummy>。
1> with
1> [
1> _Dummy = int
1> ]
翻译
错误C2065:'_SH_DENYNO':未声明的标识符
参见正在编译的类 - 模板的实例化
$ b因为在libCURL中有一个名为 share.h
的文件。 $ b
解决方案
$ b
您应将其重命名为 curl_share.h
&全部取代
#includeshare.h
由
#includecurl_share.h
I use libcurl and I get these errors without writting any code just compiling and I don't know why
Fehler 49 error C2628: '$UnnamedClass$0x05e5b255$395$' gefolgt von 'bool' unzulässig (Semikolon ';' vergessen?) c:\users\ttg\desktop\curl-7.21.7\lib\setup_once.h 273
Fehler 50 error C2065: '_SH_DENYNO': nichtdeklarierter Bezeichner C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xiosbase 111
first is a libcurl file and it says it's followed by bool(forgot semicolon?)
second undeclared identifier
this is the whole code
#pragma once
#include <curl/curl.h>
#include <curl/easy.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
namespace fr {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
// assert(bodyfile == (FILE*) stream); //this assertion fails, but when i comment it, code works. Why?
int written = fwrite(ptr, size, nmemb, (FILE *)stream);
return written;
}
/// <summary>
/// Zusammenfassung für Form1
///
/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
/// die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
/// das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
/// Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
/// arbeiten, die diesem Formular zugewiesen sind.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Konstruktorcode hier hinzufügen.
//
}
protected:
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
protected:
protected:
private:
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
void InitializeComponent(void)
{
this->SuspendLayout();
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 262);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void backgroundWorker1_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
CURL *curl_handle;
const char *headerfilename = "head.out";
FILE *headerfile;
const char *bodyfilename = "body.html";
FILE *bodyfile;
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://url");
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
headerfile = fopen(headerfilename,"w");
if (headerfile == NULL) {
curl_easy_cleanup(curl_handle);
return;
}
bodyfile = fopen(bodyfilename,"w");
if (bodyfile == NULL) {
curl_easy_cleanup(curl_handle);
return;
}
curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, headerfile);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, bodyfile);
curl_easy_perform(curl_handle);
fclose(headerfile);
fclose(bodyfile);
curl_easy_cleanup(curl_handle);
}
};
}
that's the explanation for second problem:
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xiosbase(111) : error C2065: '_SH_DENYNO': nichtdeklarierter Bezeichner
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xiosbase(196): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::_Iosb<_Dummy>".
1> with
1> [
1> _Dummy=int
1> ]
translation
error C2065: '_SH_DENYNO': undeclared identifier
See reference to the instantiation of the classes-template being compiled
解决方案
Because of there's a file named share.h
in libCURL.
You should rename it into curl_share.h
& replace all
#include "share.h"
by
#include "curl_share.h"
这篇关于libcurl编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!