You are viewing a single comment's thread from:

RE: (임시/미해결)Visual Studio 2017에서 curl 라이브러리 설치하고 사용하기

in #vs20176 years ago (edited)

저도 같은 문제로 고생하고 있었는데 방법을 찾은것 같아 글을 남깁니다.

작성자분께서 한 작업을 모두 끝마지고 11번과 같이 계속 링킹에러가 발생하였는데요
wldap32.lib와 ws2_32.lib를 추가해주고 해결이 되었습니다.
추가하는 방법은 두가지입니다.

(1)
비표준 방법입니다. 임시로 쓰세요.
헤더 #include <curl/curl.h> 밑에 아래 pragma comment를 적어줍니다.

#pragma comment (lib, "wldap32.lib")
#pragma comment (lib, "ws2_32.lib")

(2)
솔루션 탐색기에서 프로젝트에 마우스를 올려놓고 오른쪽 클릭 > 속성창 열기
링커 > 입력 > 추가 종속성 > 편집에 들어가서
위의 wldap32.lib; ws2_32.lib 를 적어줍니다.

#include "pch.h"
#include <iostream>

extern "C" {
#include <curl/curl.h>
}


#pragma comment (lib, "wldap32.lib")
#pragma comment (lib, "ws2_32.lib")


int main()
{
    std::cout << "Hello World!\n"; 

    CURL *curl;
    CURLcode res;

    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "http://ds31x.blogspot.com/2015/01/howto-dll-lib.html");
        /* example.com is redirected, so we tell libcurl to follow redirection */
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        /* Check for errors */
        if (res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n",
                curl_easy_strerror(res));

        /* always cleanup */
        curl_easy_cleanup(curl);
    }
    return 0;
}

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 62684.33
ETH 2456.60
USDT 1.00
SBD 2.66