SFML community forums

Help => Network => Topic started by: Niely on April 23, 2016, 03:53:44 pm

Title: Basic FTP code crashes at runtime
Post by: Niely on April 23, 2016, 03:53:44 pm
Hello

This basic FTP-code ain't working for some reason. I don't get an error while compiling, but only when running.

Code:
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Network.hpp>

using namespace std;
int main() {
        sf::Ftp ftp;
        sf::Ftp::Response resp;
       
        //I have emptied these variables for this post
        string server = "";
        string user = "";
        string pass = "";
        string file = "";
        string dest = "";
       
        resp = ftp.connect(server, 21, sf::seconds(120));
        if (!resp.isOk()) cout << resp.getMessage() << " " << resp.getStatus() << endl;
       
        resp = ftp.login(user, pass);
        if (!resp.isOk()) cout << resp.getMessage() << " " << resp.getStatus() << endl;
       
        resp = ftp.download(file, dest, sf::Ftp::Ascii);
        if (!resp.isOk()) cout << resp.getMessage() << " " << resp.getStatus() << endl;
       
        ftp.disconnect();
        cin.ignore().get();
        return 0;
}

G++:
Quote
g++ c:/users/name/desktop/test3.cpp -o c:/users/name/desktop/test3 -lsfml-system -lsfml-network -std=c++11

I am using Windows 8.1, and MinGW to use G++.
I have no compiling errors, only when I execute the executable (test3.exe) I get the "test3.exe doesn't work anymore, search online for solutions ...".

Details of that error:
Probleemhandtekening:
  Gebeurtenisnaam van probleem: APPCRASH
  Naam van de toepassing:       test3.exe
  Versie van toepassing:        0.0.0.0
  Tijdstempel van toepassing:   571b7a03
  Naam van foutmodule:  libstdc++-6.dll
  Versie van foutmodule:        0.0.0.0
  Tijdstempel van foutmodule:   55b39025
  Uitzonderingscode:    c0000005
  Uitzonderingsmarge:   00021225
  Versie van besturingssysteem: 6.3.9600.2.0.0.768.101
  Landinstelling-id:    2067
  Aanvullende informatie 1:     5861
  Aanvullende informatie 2:     5861822e1919d7c014bbb064c64908b2
  Aanvullende informatie 3:     bb02
  Aanvullende informatie 4:     bb02c3b29c3f075104f1d0629e885cfc
 
Translation to English (https://translate.google.com/#nl/en/Probleemhandtekening%3A%0A%20%20Gebeurtenisnaam%20van%20probleem%3A%09APPCRASH%0A%20%20Naam%20van%20de%20toepassing%3A%09test3.exe%0A%20%20Versie%20van%20toepassing%3A%090.0.0.0%0A%20%20Tijdstempel%20van%20toepassing%3A%09571b7a03%0A%20%20Naam%20van%20foutmodule%3A%09libstdc%2B%2B-6.dll%0A%20%20Versie%20van%20foutmodule%3A%090.0.0.0%0A%20%20Tijdstempel%20van%20foutmodule%3A%0955b39025%0A%20%20Uitzonderingscode%3A%09c0000005%0A%20%20Uitzonderingsmarge%3A%0900021225%0A%20%20Versie%20van%20besturingssysteem%3A%096.3.9600.2.0.0.768.101%0A%20%20Landinstelling-id%3A%092067%0A%20%20Aanvullende%20informatie%201%3A%095861%0A%20%20Aanvullende%20informatie%202%3A%095861822e1919d7c014bbb064c64908b2%0A%20%20Aanvullende%20informatie%203%3A%09bb02%0A%20%20Aanvullende%20informatie%204%3A%09bb02c3b29c3f075104f1d0629e885cfc)

Also note, that when I request a non existing file on the server, I get a SFML-error but the executable itself doesn't crashes. It only crashes when the file actually does exist...

Why ain't this basic code working?

Thanks!
Title: Re: Basic FTP code crashes at runtime
Post by: eXpl0it3r on April 24, 2016, 12:12:29 am
Might be a configuration issue. Get the debug libs, build your application in debug mode and run it through GDB to get a call stack.

Does the FTP example work that is shipped with SFML?
Title: Re: Basic FTP code crashes at runtime
Post by: Niely on April 24, 2016, 11:13:54 am
GDB finds this error:
Quote
Program received signal SIGSEGV, Segmentation fault.
0x6fc61225 in ?? () from c:\users\name\desktop\libstdc++-6.dll
(gdb) continue
Continuing.
[Inferior 1 (process 2652) exited with code 030000000005]
(gdb)
This segmentation fault occurs at line 26.

Maybe I have to mention that I have copied several .dll files to my desktop where the .exe is located.
Otherwise I got the typical error: "Can't start program because X.dll not found".

And all other FTP functions like rename, changeDirectory, login,... are working correctly.
Title: AW: Basic FTP code crashes at runtime
Post by: eXpl0it3r on April 24, 2016, 11:27:43 am
Can you give the call stack from GDB?

I meant if the FTP example executable that gets shipped with the SFML packages works.

Where did you copy the DLLs from?
Title: Re: Basic FTP code crashes at runtime
Post by: Niely on April 24, 2016, 11:49:46 am
No that example also ain't working. I get the error that specific DLLs are missing.
I copied them from the MinGW lib folder, however, it asks for a dll now I can't find in that folder.
Title: Re: Basic FTP code crashes at runtime
Post by: Niely on April 24, 2016, 11:59:17 am
Never mind,
I found all the required DLLs and just had to recompile the program.

But anyway,
The whole Ftp example program is working, but when I choose the download-option I get the exact same error as I described above.
Title: AW: Basic FTP code crashes at runtime
Post by: eXpl0it3r on April 24, 2016, 03:39:53 pm
Sounds like your compiler version isn't the exact same that was used for the downloadable packages.
Title: Re: Basic FTP code crashes at runtime
Post by: Niely on April 24, 2016, 04:16:42 pm
Windows 8.1 64-bit I'm using G++ 4.9.3, what do I have to download then?
SFML only has up to 4.9.2 and I can't get 4.9.3 because I'm using MinGW.