gpt4 book ai didi

即使使用 -lwininet 链接器标志,C++ wininet 也 undefined reference

转载 作者:行者123 更新时间:2023-11-30 16:43:18 25 4
gpt4 key购买 nike

我是 WinInet 新手,有以下简单的 C++ 代码:

void DoIt(std::string& host, std::string& username, std::string& password) {
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet == NULL) {
std::cout << "Error: " << GetLastError();
} else {
hFtpSession = InternetConnect(hInternet, host.c_str(), INTERNET_DEFAULT_FTP_PORT, username.c_str(), password.c_str(), INTERNET_SERVICE_FTP, 0, 0);
if (hFtpSession == NULL) {
std::cout << "Error: " << GetLastError();
} else {
if (!FtpPutFile(hFtpSession, "C:\\temp\\ftp\\myFile.txt", "/myFile.txt", FTP_TRANSFER_TYPE_BINARY, 0)) {
std::cout << "Error: " << GetLastError();
}
}
}
}

但是编译器的输出是:

Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -std=c++11 -o main.o "..\\main.cpp"
C:\Users\u007\AppData\Local\Temp\ccFEaWlK.o: In function `Z4DoItRSsS_S_':
C:\projects\ftp-test\Debug/../main.cpp:10: undefined reference to `_imp__InternetOpenA@20'
C:\projects\ftp-test\Debug/../main.cpp:14: undefined reference to `_imp__InternetConnectA@32'
C:\projects\ftp-test\Debug/../main.cpp:18: undefined reference to `_imp__FtpPutFileA@20'
collect2.exe: error: ld returned 1 exit status

(我链接到 Eclipse 链接器中的 wininet.lib 库) Adding <code>wininet.lib</code> in Eclipse

(我还尝试向编译器添加 -lwininet 选项,但它什么也没做)

我使用以下软件:

  • 操作系统:Windows 10 x64
  • IDE:Eclipse Neon 3
  • 编译器:MinGW (rubenvb-4.8-stdthread) 4.8.1 20130324(预发布)

我看到以下链接:1 2 3但那里没有任何帮助我。

感谢您的任何建议。

最佳答案

基于 g++ 编译行,它缺少要链接到的库 (wininet)。您需要在 Eclipse 中添加该库,以便您的程序链接到它。

关于即使使用 -lwininet 链接器标志,C++ wininet 也 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45373024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com