Hello there,
I had a problem when trying to connect and upload a file to an FTP server.
Here's my code:
#include <windows.h> #include <wininet.h> #pragma comment(lib, "wininet.lib") int main() { HINTERNET hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); HINTERNET hFtpSession = InternetConnect(hInternet, L"myserver.com", INTERNET_DEFAULT_FTP_PORT, L"user", L"pass", INTERNET_SERVICE_FTP, 0, 0); if(FtpPutFile(hFtpSession, L"file.txt", L"file.txt", FTP_TRANSFER_TYPE_BINARY, 0)) { MessageBox(NULL, L"Upload Complete", L"OK", 0); } else { MessageBox(NULL, L"Upload Failed", L"OK", 0); } InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); return 0; }
and the error:
svDialog.obj : error LNK2005: "void * hFtpSession" (?hFtpSession@@3PAXA) already defined in MainDlg.obj svDialog.obj : error LNK2005: "void * hInternet" (?hInternet@@3PAXA) already defined in MainDlg.obj
am I doing wrong?
(the above code is just a simplified representation of my real program using wxWidgets and Multithreading)