SFML community forums

Help => Network => Topic started by: JoshuaBehrens on March 08, 2013, 10:10:51 pm

Title: [Solved] SFML 2RC crashes undebuggable when downloading a file
Post by: JoshuaBehrens on March 08, 2013, 10:10:51 pm
Hello guys,

I tried this:
#include <SFML/Network.hpp>

#include <map>
#include <list>
#include <string>
#include <cstdio>

bool retrieveLines( const std::string& url, const std::string& file, const std::map< std::string, std::string >& params, std::list< std::string >& out )
{
    sf::Http http( url );
    sf::Http::Request req( file );
    req.setMethod(sf::Http::Request::Get);
    req.setBody("");
    req.setHttpVersion(1, 0);
    for ( std::map< std::string, std::string >::const_iterator cit( params.begin( ) ) ; cit != params.end( ) ; ++cit )
        req.setField( cit->first, cit->second );

    sf::Http::Response res = http.sendRequest( req );

    if ( res.getStatus( ) == 200 )
    {
        printf( "body from %s:\n%s\n", url.c_str( ), res.getBody( ).c_str( ) );
        return true;
    }
    return false;
}

int main( int argc, char** args )
{
    std::map< std::string, std::string > pars;
    std::list< std::string > lines;
    retrieveLines( "joshua-behrens.de","/index.php", pars, lines );

    return 0;
}
But it always closed my console with a very high return number. It is also undebuggable. gdb stops neither on any breakpoint nor any other point where an error could occur. But gdb is fine in other projects. DLLs are with the console, I linked against network-d and system-d. Any hints?
Thanks in advance, JoshuaBehrens
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: eXpl0it3r on March 08, 2013, 11:08:02 pm
What OS are you using and which compiler version?
The title says SFML 2 RC, so you've downloaded the RC from the website?

I suspect, that you'll have to recompile SFML for your compiler (or maybe my Nightly Builds can help out).

Anyways it works fine on my end.
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: JoshuaBehrens on March 09, 2013, 10:52:59 am
Well ... Exploiter ... you helped me to compile the RC last time :D not a week ago

After a restart it started (started c::b with adminrights) and now he complains that he could not find "_ZN2sf4Http11sendRequestERKNS0_7RequestENS_4TimeE" in DLL "sfml-network-d-2.dll".
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: eXpl0it3r on March 09, 2013, 11:07:34 am
Well ... Exploiter ... you helped me to compile the RC last time :D not a week ago
Ah that was you! Well I help out so many people here on the forum, that I usually don't remember exactly whom I helped with what and only start to recognize people if they appear more regularly. ;)

Also if you have compiled SFML from GitHub then you shouldn't call it RC, because RC means Release Candidate and is just one specific type. ;)

After a restart it started (started c::b with adminrights) and now he complains that he could not find "_ZN2sf4Http11sendRequestERKNS0_7RequestENS_4TimeE" in DLL "sfml-network-d-2.dll".
Make sure that you're IDE is set to debug mode, that you've linked SFML in the correct order (graphics, window, network, system) and that SFML_STATIC is not defined.
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: JoshuaBehrens on March 09, 2013, 11:42:08 am
I start C::B as admin (so the toolchain should too?) I just link against network and system using this command: -lsfml-network-d -lsfml-system-d, SFML_STATIC is not defined due to this snippet in front
#ifdef SMFL_STATIC
    #error does not work with static
#endif // SMFL_STATIC
and it compiled fine.

The compiled application asks for sfml-network-d-2.dll, but I only have sfml-network-d.dll from the compilation of SFML 2. I renamed the dll then I throws this error.

than I just say I used the latest SFML 2 ^^

I would also be fine when I have to use boost::asio, because it's just about a filedownload, but SFML has an easier interface for http.
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: Laurent on March 09, 2013, 02:14:56 pm
Quote
The compiled application asks for sfml-network-d-2.dll, but I only have sfml-network-d.dll from the compilation of SFML 2
So there's obviously something wrong, you should never have to manually rename files ;)

How did you recompile SFML?
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: JoshuaBehrens on March 09, 2013, 03:20:20 pm
http://en.sfml-dev.org/forums/index.php?topic=10619.msg74483#msg74483
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: Laurent on March 09, 2013, 03:24:37 pm
In this video, the filenames are correct.
Title: Re: SFML 2RC crashes undebuggable when downloading a file
Post by: JoshuaBehrens on March 09, 2013, 03:41:15 pm
Well I just recompiled all ... and well it works now. Creepy sfml-bins I have. I have no idea why they were not named sfml 2. But it worked as you can see here: http://de.twitch.tv/joshuabehrens/b/375614633