#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: