首页 > 解决方案 > C++ WinHTTP 库生成符号错误

问题描述

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

错误

这真的让我很困惑如何修复它,因为我没有在 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;
}

标签: c++linkerwinhttp

解决方案


推荐阅读