C ++: Libcurl curl_easy_init () gives access violation error and program crash

I am trying to use libcurl with the program I am creating, but I have problems with it. So far, I have only tried examples from the libcurl website, but they crash as soon as the program gets into curl initialization.

My current code is:

#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;
}

I also made sure that the compiler and linker can find the resources and that the DLL file (libcurl.dll) is in the program folder, but it continues to fail. I tried debugging with VS2010, and it gave me an "access violation" error when initializing the curl_easy_init () function.

Any help would be appreciated!

+3
source share
3 answers

DLL. PATH libcurl.dll.

, VS2010 professional MSVC 7.18.0/Win32 generic, .

+2

ok (ubuntu box):

#g++ -lcurl url.c -o url

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Garry Mod Finland - Etusivu</title>
    <meta h ....
+1

, . , , Windows, , . .

, , . - .

0

Source: https://habr.com/ru/post/1771174/


All Articles