开发者

libcurl compile errors

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"


Adjust you your include path only to c:\users\ttg\desktop\curl-7.21.7\include and not to include c:\users\ttg\desktop\curl-7.21.7\lib also.

in the lib directory there is a share.h in root the conflicts with VC\include\share.h.


Taking a wild guess, I would say you are compiling C, but including C++ headers. <string> <sstream> and <iostream> are C++ headers.


You can fix the error about bool by defining HAVE_BOOL_T in your preprocessor and TWO files named share.h were referenced in your project, one in libcurl and another in your standard template library, that's why you get such errors about _SH_DENYNO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜