Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Program do wysyłania plików na serwer ftp Błąd


Rekomendowane odpowiedzi

Opublikowano

Witam.

Mam problem z programem który pisze do wysyłania jednego konkretnego pliku na serwer ftp. Program nie uruchamia się... Wyskakuje raport błędu :

undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
[...]

recipe for target 'Sender1.0.exe' failed

mingw32-make.exe: *** [sender1.0.exe] Error 1
 
w makefile.win błędna linijka:
 
	$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)

Proszę o szybką pomoc. O pomoc w naprawie lub podesłanie jakiegoś linku do poradnika który może mi pomóc gdyż jestem początkujący.

 
 

 

C++ :

#include <Windows.h>
#include <wininet.h>
#include <iostream>
#pragma comment (lib, "Wininet.lib");

using namespace std;


int WyslijPlik(){

    char ftp[]      = "adres_ftp";

    char user[]     = "Login";

    char password[] = "hasło";
    
    char localFile[] = "adres_pliku.txt";

    char remoteFile[] = "adres_pliku_na_serwerze_ftp.txt";
  
    HINTERNET hInternet;

    HINTERNET hFtpSession;     

    if(InternetAttemptConnect(0) == ERROR_SUCCESS) cout<<"Internet dostepny, wysylanie pliku..\n"<<endl;

    else {cout<<"Internet niedostepny.\n"<<endl; return -1;}
 

    hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL,0);

    if(hInternet != NULL){     

        hFtpSession = InternetConnect(hInternet, ftp, INTERNET_DEFAULT_FTP_PORT, user, password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);

        if(hFtpSession != NULL){

            if(FtpPutFile(hFtpSession, localFile, remoteFile , FTP_TRANSFER_TYPE_BINARY,0)){                

                InternetCloseHandle(hFtpSession);

                InternetCloseHandle(hInternet);

                }
            else {                              
                cout<<"Blad podczas wysylania pliu."<<endl;
                return -1;
            }   
            

        }
        
        else return -1;
        

    }

    else  return -1;

    cout<<"Wyslano Plik.\n"<<endl;  

    return 0;

};
Opublikowano

Mógłbyś wpisać ją w mój kod ? Próbowałem dodać ale tak jak pisałem jestem początkujący i zgaduje że coś źle robię że mam nowe błędy 

int main(int argc, char* argv[])
{
    WyslijPlik();
    return 0;
}

Skończ proszę się kompromitować. Jesteś nikim.

Opublikowano
#include <Windows.h>
#include <wininet.h>
#include <iostream>
#pragma comment (lib, "Wininet.lib");
 
using namespace std;
 
int main(int argc, char* argv[])
{
 
    WyslijPlik(){
    return 0;
}
    char ftp[]      = "adres_ftp";
 
    char user[]     = "Login";
 
    char password[] = "hasło";
    
    char localFile[] = "adres_pliku.txt";
 
    char remoteFile[] = "adres_pliku_na_serwerze_ftp.txt";
  
    HINTERNET hInternet;
 
    HINTERNET hFtpSession;     
 
    if(InternetAttemptConnect(0) == ERROR_SUCCESS) cout<<"Internet dostepny, wysylanie pliku..\n"<<endl;
 
    else {cout<<"Internet niedostepny.\n"<<endl; return -1;}
 
 
    hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL,0);
 
    if(hInternet != NULL){     
 
        hFtpSession = InternetConnect(hInternet, ftp, INTERNET_DEFAULT_FTP_PORT, user, password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
 
        if(hFtpSession != NULL){
 
            if(FtpPutFile(hFtpSession, localFile, remoteFile , FTP_TRANSFER_TYPE_BINARY,0)){                
 
                InternetCloseHandle(hFtpSession);
 
                InternetCloseHandle(hInternet);
 
                }
            else {                              
                cout<<"Blad podczas wysylania pliu."<<endl;
                return -1;
            }   
            
 
        }
        
        else return -1;
        
 
    }
 
    else  return -1;
 
    cout<<"Wyslano Plik.\n"<<endl;  
 
    return 0;
 
};

I mam nowe błędy(logi kompilatora):

 

Compiling single file...
--------
- Filename: C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp
- Compiler Name: TDM-GCC 4.9.2 32-bit Release
 
Processing C++ source file...
--------
- C++ Compiler: C:\Program Files\Dev-Cpp\MinGW64\bin\g++.exe
- Command: g++.exe "C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp" -o "C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.exe" -m32 -I"C:\Program Files\Dev-Cpp\MinGW64\include" -I"C:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"C:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib32" -static-libgcc -m32
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp: In function 'int main(int, char**)':
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp:11:16: error: 'WyslijPlik' was not declared in this scope
     WyslijPlik();
                ^
 
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp: At global scope:
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp:29:5: error: expected unqualified-id before 'if'
     if(InternetAttemptConnect(0) == ERROR_SUCCESS) cout<<"Internet dostepny, wysylanie pliku..\n"<<endl;
     ^
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp:31:5: error: expected unqualified-id before 'else'
     else {cout<<"Internet niedostepny.\n"<<endl; return -1;}
     ^
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp:34:5: error: 'hInternet' does not name a type
     hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL,0);
     ^
C:\Users\Nemesis\Desktop\Sender1.0\Sender1.0.cpp:36:5: error: expected unqualified-id before 'if'
     if(hInternet != NULL){     
     ^
 
 
Compilation results...
--------
- Errors: 5
- Warnings: 0
- Compilation Time: 3,41s

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...