SFML community forums

General => General discussions => Topic started by: Neo1 on October 28, 2011, 05:42:06 pm

Title: Works fine on one machine, crashes on the other?
Post by: Neo1 on October 28, 2011, 05:42:06 pm
So i've just finished a tiny hobby project that generates a random perfect maze using a randomized DFS. I coded it all on my laptop (Running Windows 7) using Code::Blocks 10.05 and MinGW with GCC 4.5.2, it's not quite finished and polished yet, but it works and runs. I use the dynamic libraries and i link against:

-lsfml-graphics-d
-lsfml-window-d
-lsfml-system-d

I define SFML_DYNAMIC and the proper DLLs are where they belong, so far so good.

So since the program runs quite slowly (I'm doing some stupid conversions and copies of some semi-large vectors in my main loop, as i said, not quite finished yet) i wanted to try it out on my significantly faster desktop.

First of i couldn't compile the code since the GCC version didn't have the proper dll (Something with exceptions and something called Dwarf2 i believe), so i fixed this error by just uninstalling C::B and MinGW, and then installing the newest version of MinGW seperately from C::B. I then set up the new project exactly as above, it compiles like a dream, but when i run it i just get an empty console window. No renderwindow, no nothing. If i set a breakpoint just at the start of main and run it through the debugger, GDB just crashes before it even reaches main.

This machine also runs Windows 7, both MinGW and C::B is the exact same version as on my laptop. I even tried copying the executable from my laptop to the desktop, and it still just gives me an empty console window, although the exact same executable works like a dream on the laptop, with a pretty much identical setup.

What is going on here? I can post the code if need be, it's not that long, but somehow i don't think this has anything to do with the code itself.
Title: Works fine on one machine, crashes on the other?
Post by: Laurent on October 28, 2011, 07:43:04 pm
Quote
What is going on here?

ATI graphics card I guess. That's a known bug with 1.6.
Linking SFML statically should solve the problem.
Title: Works fine on one machine, crashes on the other?
Post by: Neo1 on October 28, 2011, 10:05:35 pm
Quote from: "Laurent"
Quote
What is going on here?

ATI graphics card I guess. That's a known bug with 1.6.
Linking SFML statically should solve the problem.


Correct, you're somewhat of a clairvoyant! The laptop has a tiny GMA somethingsomething, and the desktop is sporting an ATi card.

So i changed my linker options to the following:

-lsfml-graphics-s-d
-lsfml-window-s-d
-lsfml-system-s-d

I removed the SFML_DYNAMIC and i deleted the DLLs in my project folder. What else will i need to do to link statically? The program is now complaining about missing DLLs when i run it.
Title: Works fine on one machine, crashes on the other?
Post by: Laurent on October 28, 2011, 10:10:13 pm
Quote
The program is now complaining about missing DLLs when i run it.

Which one?
Title: Works fine on one machine, crashes on the other?
Post by: Neo1 on October 28, 2011, 10:15:35 pm
Quote from: "Laurent"
Quote
The program is now complaining about missing DLLs when i run it.

Which one?


sfml-graphics-d.dll
Title: Works fine on one machine, crashes on the other?
Post by: keyforge on October 28, 2011, 11:05:14 pm
So you are using SFML 1.6 correct? If you're using SFML 2.0 you need to define SFML_STATIC.

If above isn't the problem, does the release version work?
Title: Works fine on one machine, crashes on the other?
Post by: Laurent on October 29, 2011, 10:55:42 am
sfml-graphics-d.dll can only be required if you have -lsfml-graphics or -lsfml-graphics-d in your linker options.
Title: Works fine on one machine, crashes on the other?
Post by: Neo1 on October 29, 2011, 05:52:14 pm
Quote from: "Laurent"
sfml-graphics-d.dll can only be required if you have -lsfml-graphics or -lsfml-graphics-d in your linker options.


Hmm, i changed the linker options to use the static libraries, and i got the DLL-missing error. After restarting C::B the linker options had reverted to the dynamic libraries. So i changed it again and it seems to stick now. However the code won't compile with the static libraries, i get a long list of undefined references similar to this one:

undefined reference to '_imp____ZN2sf8DrawableD2EV'

Is there something else i need to do to make it work with the static libraries?
Title: Works fine on one machine, crashes on the other?
Post by: Laurent on October 29, 2011, 06:02:54 pm
SFML 1.6: don't define SFML_DYNAMIC
SFML 2.0: define SFML_STATIC