C++:Libcurl curl_easy_init() 给出访问冲突错误并使程序崩溃 [英] C++: Libcurl curl_easy_init() gives an access violation error and crashes the program

查看:81
本文介绍了C++:Libcurl curl_easy_init() 给出访问冲突错误并使程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 libcurl 与我正在制作的程序一起使用,但我遇到了一些问题.到目前为止,我只尝试了 libcurl 网站上的示例,但是一旦程序进入 curl 初始化,它们就会崩溃.

I'm trying to use libcurl with a program I'm making, but I'm having some problems with it. So far I've only tried the examples from libcurl's website, but they crash as soon as the program gets to the curl initialization.

我当前的代码:

#include <iostream>
#include <curl/curl.h>

int main(int argc, char *argv[])
{
    CURL *curl;
    CURLcode res;

    curl = curl_easy_init();
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_URL, "http://garrysmod.fi/");
        res = curl_easy_perform(curl);

        curl_easy_cleanup(curl);
    }

    return 0;
}

我还确保编译器和链接器可以找到资源,并且 dll 文件 (libcurl.dll) 位于程序的文件夹中,但它一直崩溃.我尝试使用 VS2010 进行调试,它在初始化函数 curl_easy_init() 中给了我一个访问冲突"错误.

I have also made sure the compiler and linker can find the resources, and that the dll file (libcurl.dll) is in the program's folder, yet it keeps crashing. I tried debugging with VS2010, and it gave me an "access violation" error at the initialization function curl_easy_init().

任何帮助将不胜感激!

推荐答案

这几乎肯定是 DLL 的不匹配.首先检查您的 PATH 是否有任何旧版本或不同版本的 libcurl.dll.

This is almost certainly a mismatch of DLL's. Firstly check on your PATH for any older or different versions of libcurl.dll.

我刚刚针对此版本使用 VS2010 专业版为 构建了您的代码段MSVC 7.18.0/Win32 通用,它运行良好.

I just built your snippet using VS2010 professional against this release for MSVC 7.18.0 / Win32 generic and it worked fine.

这篇关于C++:Libcurl curl_easy_init() 给出访问冲突错误并使程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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