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

Author Topic: Can't get SFML 1.4 to work properly!  (Read 10723 times)

0 Members and 1 Guest are viewing this topic.

__fastcall

  • Newbie
  • *
  • Posts: 8
    • View Profile
Can't get SFML 1.4 to work properly!
« on: April 02, 2009, 09:32:15 am »
Code: [Select]

#include <sfml/System.hpp>
#include <sfml/Graphics.hpp>
#include <sfml/Window.hpp>
#include <iostream>

// #define STATIC

#ifdef STATIC
# ifdef DEBUG
# pragma comment( lib, "sfml-graphics-s-d.lib")
# pragma comment( lib, "sfml-window-s-d.lib")
# pragma comment( lib, "sfml-system-s-d.lib")
# else
# pragma comment( lib, "sfml-graphics-s.lib")
# pragma comment( lib, "sfml-window-s.lib")
# pragma comment( lib, "sfml-system-s.lib")
# endif
#else
# ifdef DEBUG
# pragma comment( lib, "sfml-graphics-d.lib")
# pragma comment( lib, "sfml-window-d.lib")
# pragma comment( lib, "sfml-system-d.lib")
# else
# pragma comment( lib, "sfml-graphics.lib")
# pragma comment( lib, "sfml-window.lib")
# pragma comment( lib, "sfml-system.lib")
# endif
#endif

int main( int, char*[] )
{
sf::RenderWindow rw(sf::VideoMode(800, 600), "SFML window");

std::cout << "Hello world.\n";

return 0;
}


The code above compiles and links without any errors or warnings with the dynamic libraries.  However, it does not run; when I break the execution, the program seems to be stuck in an infinate loop inside ntdll.dll.

I tried linking with the static libraries, with only this warning:
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

The program runs and the window displays, unfortunately, on its way out I get this message:
"Run-Time Check Failure #2 - Stack around the variable 'rw' was corrupted."


Adding this code after rw is declared ...:

rw.Clear( sf::Color( 255, 0, 0 ) );

... Resulted in this message on exit:
"A buffer overrun has occurred in sfml-arg-d.exe which has corrupted the program's internal state."

Ignoring the MSVCRT library breaks all the other libraries with Unresolved External Symbols.  I tried the same thing with the tutorial code, with the same results.  I get the same results trying to mix my code linking with the "Multithreaded Deubg DLL" and "Multithreaded Debug" versions of the runtime library.   I've also tried rebuilding the SFML 1.4 libraries, but unfortunately it didn't change anything.  Viewed the static-built exe and the dynamic-linked exe under dependency walker, with nothing appearing out of the ordinary...

So...
I can't use SFML 1.4 dynamic libraries, since it locks up before the program loads, and I can't use SFML 1.4 static libraries, because it's buggy and unpredictable.


What's the heck is going on?!   :evil:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't get SFML 1.4 to work properly!
« Reply #1 on: April 02, 2009, 01:59:44 pm »
You should not use pragmas to setup your linker. Do it in your project's settings. The DEBUG macro might not be defined, actually the only "standard" macro you should expect to be defined is NDEBUG for non-debug builds.
But anyway, use your project settings ;)
Laurent Gomila - SFML developer

__fastcall

  • Newbie
  • *
  • Posts: 8
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #2 on: April 02, 2009, 07:14:55 pm »
Quote from: "Laurent"
You should not use pragmas to setup your linker. Do it in your project's settings.  ... Use your project settings ;)



Thanks!

It works with the static libraries, however, I get the same problem linking to the dynamic libraries -- the program freezes somewhere in ntdll.dll before the program runs.

Any idea why?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't get SFML 1.4 to work properly!
« Reply #3 on: April 02, 2009, 07:16:50 pm »
Yep, you probably have a USB joystick ;)
Unplug it and try again.
Laurent Gomila - SFML developer

__fastcall

  • Newbie
  • *
  • Posts: 8
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #4 on: April 02, 2009, 07:55:29 pm »
Quote from: "Laurent"
Yep, you probably have a USB joystick ;)
Unplug it and try again.


 :shock:
Thanks again! It works completely now!   :D

But seriously ... WTF?!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't get SFML 1.4 to work properly!
« Reply #5 on: April 02, 2009, 08:22:22 pm »
I know, it's pretty weird. This is a well known bug in SFML 1.4, caused by the internal initialization of joysticks at startup, which causes the program to freeze for some reason. This has been fixed in the latest sources, that you can get with SVN.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Can't get SFML 1.4 to work properly!
« Reply #6 on: April 02, 2009, 11:54:10 pm »
Quote from: "Laurent"
The DEBUG macro might not be defined, actually the only "standard" macro you should expect to be defined is NDEBUG for non-debug builds.
In debug configuration, MSVC++ normally defines the _DEBUG macro (with underscore).

Quote from: "Laurent"
Yep, you probably have a USB joystick ;)
Unplug it and try again.
You've got a nice crystal ball. ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #7 on: April 03, 2009, 03:42:39 am »
Quote from: "Nexus"

Quote from: "Laurent"
Yep, you probably have a USB joystick ;)
Unplug it and try again.
You've got a nice crystal ball. ;)


Not really.. It's a know bug of sfml 1.4 and he's easy to identify.
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

charlieh

  • Newbie
  • *
  • Posts: 1
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #8 on: April 09, 2009, 03:13:06 am »
Is there a clean way to disable joystick support without hacking the source code, until this bug is fixed?

Edit: Oops! I guess this is fixed in SVN.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't get SFML 1.4 to work properly!
« Reply #9 on: April 09, 2009, 08:35:39 am »
Quote
Oops! I guess this is fixed in SVN.

Indeed it is.
Laurent Gomila - SFML developer

Joh

  • Newbie
  • *
  • Posts: 6
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #10 on: May 12, 2009, 09:22:41 pm »
Quote from: "Laurent"
Quote
Oops! I guess this is fixed in SVN.

Indeed it is.

Sorry for the necro but, it is? I just compiled from SVN and now I'm getting no joystick input at all. I guess it's better than a deadlock, but we're in desperate need of joystick input for our project. Any specific revision we should turn to, or do we have to look for another lib for input?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't get SFML 1.4 to work properly!
« Reply #11 on: May 12, 2009, 10:58:14 pm »
Joystick input is supposed to work fine.
What joystick are you using? What OS?
Laurent Gomila - SFML developer

Joh

  • Newbie
  • *
  • Posts: 6
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #12 on: May 13, 2009, 12:16:55 am »
I'm using 32-bit XP with a PS2 adapter to connect a PS2 controller to the system. It's working fine in the control panel, and it's working fine everywhere I've tried it. I do not get a single joystick event under SFML however.

Edit: The PS2 controller is just for testing purposes and are not the controllers we will use as final controllers. We do not have access to the joysticks we will be using yet, however.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't get SFML 1.4 to work properly!
« Reply #13 on: May 13, 2009, 12:29:34 am »
Can you show the relevant pieces of code?
Laurent Gomila - SFML developer

Joh

  • Newbie
  • *
  • Posts: 6
    • View Profile
Can't get SFML 1.4 to work properly!
« Reply #14 on: May 13, 2009, 12:57:14 am »
The only really relevant code is from the event loop:

Code: [Select]
if (_window)
{
sf::Event event;

while (_window->GetEvent(event))
{
std::cout << event.Type << std::endl;

for (std::vector<EventHandler*>::iterator iter = _handlers.begin(); iter != _handlers.end(); iter++)
{
if ((*iter)->handleEvent(event))
break;
}
}
}


I redirected stdout to a file and searched for joystick events, not a single one of the events raised are joystick events, no matter how much I keep moving the axises or pressing the buttons.

 

anything