Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Basic FTP code crashes at runtime  (Read 3962 times)

0 Members and 1 Guest are viewing this topic.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Basic FTP code crashes at runtime
« 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

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!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Basic FTP code crashes at runtime
« Reply #1 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Basic FTP code crashes at runtime
« Reply #2 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.
« Last Edit: April 24, 2016, 11:25:05 am by Niely »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
AW: Basic FTP code crashes at runtime
« Reply #3 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Basic FTP code crashes at runtime
« Reply #4 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.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Basic FTP code crashes at runtime
« Reply #5 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
AW: Basic FTP code crashes at runtime
« Reply #6 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Basic FTP code crashes at runtime
« Reply #7 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.
« Last Edit: April 24, 2016, 06:35:54 pm by Niely »

 

anything