C ++ WinHTTP库生成符号错误

时间:2018-05-25 13:01:20

标签: c++ linker winhttp

我正在编译以下代码并获得以下错误:

errors

这让我对如何修复它感到困惑,因为我没有在Visual Studio中看到任何突出显示的错误,并且我已经研究/遵循了文档。

我尝试阅读链接器文档,但它在我的上下文中没有意义。我还尝试确保传递所有正确的参数:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <windows.h>
#include <WinHttp.h>

int main()
{
    HINTERNET hSession = NULL, hConnect = NULL, hRequest = NULL;
    hSession = WinHttpOpen(L"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36",
        WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);

    //make the connection request
    if (hSession) {
        hConnect = WinHttpConnect(hSession, L"http://api", 80, 0);
    }
    else {
        printf("error: %d", GetLastError());
    }

    // open the request - not connected at this point
    hRequest = WinHttpOpenRequest(hConnect, L"GET", NULL, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, 0);

    //
    int x;
    std::cin >> x;

    return 0;
}

0 个答案:

没有答案