Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ libcurl-x32 DLL的运行时异常_C++_Curl_Dll_Runtime Error_Libcurl - Fatal编程技术网

C++ libcurl-x32 DLL的运行时异常

C++ libcurl-x32 DLL的运行时异常,c++,curl,dll,runtime-error,libcurl,C++,Curl,Dll,Runtime Error,Libcurl,我已从http://www.confusedbycode.com/curl/(直接链接到存档,无需安装程序)。我将curl-7.45.0-win32\lib中的libcurl.lib放入VisualStudio2015项目并编译。它工作得很好(我使用x64 Windows 10,但项目是x86) 然后我将curl-7.45.0-win32\DLLs中的DLL文件放入: 但是当我运行程序(从Visual Studio,调试模式)时,我得到了运行时错误: 在MyProgram.exe 0xC000

我已从
http://www.confusedbycode.com/curl/
(直接链接到存档,无需安装程序)。我将
curl-7.45.0-win32\lib
中的
libcurl.lib
放入VisualStudio2015项目并编译。它工作得很好(我使用x64 Windows 10,但项目是x86)

然后我将
curl-7.45.0-win32\DLLs
中的DLL文件放入:

但是当我运行程序(从Visual Studio,调试模式)时,我得到了运行时错误:

在MyProgram.exe 0xC00000005中的0x52874918(libcurl.dll)处引发异常:访问冲突读取位置0x00000000

当我从
curl-7.45.0-win64\DLLs
中放入x64 DLL时,它表示程序没有正确启动。如果没有DLL,程序会警告我它找不到它们

因此,我猜来自
curl-7.45.0-win32\DLLs
的DLL是正确的,但是我在这里做错了什么?

我几乎可以肯定,这项计划几天前还在运作

我在项目设置(默认设置)中更改的内容只有:

  • 字符集:使用Unicode字符集
  • 运行库:多线程调试(/MTd)
  • 我添加来测试curl的源代码基于它们的一个示例(在
    test.cpp
    中):

    WriteCallback
    Test.h
    中定义:

    #define CURL_STATICLIB
    #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;
    }
    
    class Test {
    public:
        bool test(...);
    }
    
    #定义CURL\u STATICLIB
    #包括
    静态大小写回(void*contents、size\t size、size\t nmemb、void*userp){
    ((std::string*)userp)->追加((char*)内容,大小*nmemb);
    返回大小*nmemb;
    }
    课堂测试{
    公众:
    布尔检验(…);
    }
    
    让我冒昧猜一猜。错误在代码中的某个地方@n、 m.我认为它与DLL的版本有关,因为源代码基于curl sample。我已经用源代码扩展了这个问题。我建议在调试模式下构建您自己的libcurl版本,并在其上使用调试器。我将支持这个建议。Windows和二进制下载DLL的组合是一堆蠕虫,它们只是为了解决由于内存模型、编译器约定等原因而产生的问题。libcurl是完全开放的,可以很容易地构建自己来避免这种问题。
    #define CURL_STATICLIB
    #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;
    }
    
    class Test {
    public:
        bool test(...);
    }