简体   繁体   English

尝试 urldownloadtofile 函数时出错

[英]Error When trying the urldownloadtofile function

Getting error when using urldownloadtofile the error is : undefined reference to `URLDownloadToFileA'使用 urldownloadtofile 时出错,错误是:未定义对 `URLDownloadToFileA' 的引用

#include <iostream>
#include <Windows.h>
#include <string>
#pragma comment(lib, "urlmon.lib")

using namespace std;
int main()
{   
    string dwnld_URL = "http://www.412312myfuptoload.com/downloadpage/Honeygain.exe";
    string savepath = "C:\\Users\\Ester\\Appdata\\Roaming\\Honeygain.exe";
    URLDownloadToFile(NULL, dwnld_URL.c_str(), savepath.c_str(), 0, NULL);

    return 0;
}

#pragma comment(lib, "urlmon.lib") works with MSVC (or compatible) compiler. #pragma comment(lib, "urlmon.lib")适用于 MSVC(或兼容)编译器。

From the error and your previous question it seems you are using MinGW (ld linker) instead, which doesn't support it.从错误和您之前的问题来看,您似乎正在使用不支持它的 MinGW(ld 链接器)。

So you should link with the -lurlmon option.所以你应该使用-lurlmon选项链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM