简体   繁体   English

Wininet给出了链接器错误,我正在使用devc ++

[英]Wininet giving linker errors I'm using devc++

#include <iostream>
#include <windows.h>
#include <wininet.h>
#pragma comment(lib, "wininet")
#include <pshpack4.h>
#include <poppack.h>
using namespace std;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

{
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
hFtpSession = InternetConnect(hInternet, "ftp.drivehq.com",INTERNET_DEFAULT_FTP_PORT, "usr" ,"pass", INTERNET_SERVICE_FTP, 0, 0);
FtpPutFile(hFtpSession, "log.txt", "mylog.txt", FTP_TRANSFER_TYPE_BINARY, 0);

InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);

return 0;
}
[Linker error] undefined reference to `InternetOpenA@20' 
[Linker error] undefined reference to `InternetConnectA@32' 
[Linker error] undefined reference to `FtpPutFileA@20' 
[Linker error] undefined reference to `InternetCloseHandle@4' 
[Linker error] undefined reference to `InternetCloseHandle@4' 
ld returned 1 exit status 
C:\Users\Wade\Desktop\test\command builder\Makefile.win [Build Error]  [command.exe] Error 1

What's wrong with my code here it keeps giving me linker errors? 我的代码有什么问题,它总是给我链接器错误?

I had many errors like this on my first C++ program. 我的第一个C ++程序有很多这样的错误。 It is a problem with linking against the WinINet library. 与WinINet库链接时出现问题。 If you are using MinGW add "-lwininet" (without quotes) to the additional commandling arguments and it should be fixed. 如果您使用的是MinGW,请在其他命令参数中添加“ -lwininet”(不带引号),并且应将其固定。 I don't know what to to do if you use VC++. 如果您使用VC ++,我不知道该怎么办。 Also, make sure the location of the WinINet library is in the linker's search paths. 另外,请确保WinINet库的位置在链接器的搜索路径中。 One other note: The INTERNET_PER_CONN_* variables, along with a few others, do not exist in MinGW's WinInet, and I have not found a solution to fixing it yet. 另一个注意事项:MinGW的WinInet中不存在INTERNET_PER_CONN_ *变量,还有一些其他变量,我还没有找到解决该问题的解决方案。

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

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