这是代码
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <urlmon.h>
#pragma comment(lib, "Urlmon.lib")
using namespace std;
void cls()
{
system("cls");
}
int main()
{
const char* url = "http://baidu.com";
const char* file_name = "index.html";
HRESULT result = URLDownloadToFileA(NULL, url, file_name, 0, NULL);
return 0;
}
报错信息
C:\User\404NotFound\AppDta\Local\Temp\cck9VLF.o main.cpp:(.text+61) : undefined reference to URLDownloadToFileA
C:\User\404NotFound\桌面\collect2.exe [Error] ld returned 1 exit status
百度过了没用
你没有连接他的静态库
#pragma comment(lib, "Urlmon.lib")这是微软的东西,Visual Studio中倒是可以用。
工具>编译器选项,后面添加:-lurlmon