C++ wininet undefined reference even with -lwininet linker flag -
i'm new wininet , have following simple c++ code:
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(); } } } }
but compiler's output is:
info: configuration "debug" uses tool-chain "mingw gcc" unsupported on system, attempting build anyway. info: internal builder used 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 `_imp__internetopena@20' c:\projects\ftp-test\debug/../main.cpp:14: undefined reference `_imp__internetconnecta@32' c:\projects\ftp-test\debug/../main.cpp:18: undefined reference `_imp__ftpputfilea@20' collect2.exe: error: ld returned 1 exit status
(i link wininet.lib
library in eclipse's linker)
(i tried add -lwininet
option compiler nothing)
i use following software:
- os:
windows 10 x64
- ide:
eclipse neon 3
- compiler:
mingw (rubenvb-4.8-stdthread) 4.8.1 20130324 (prerelease)
i saw following links: 1 2 3 nothing there helps me.
thanks suggestion.
based on g++ compile line it's missing library link (wininet). need in eclipse add library program link it.
Comments
Post a Comment