SFML community forums

Help => General => Topic started by: NiGhMa on October 08, 2017, 12:25:47 pm

Title: Static linking
Post by: NiGhMa on October 08, 2017, 12:25:47 pm
Hi,

I've got a strange behavior with static linking. My little game works fine but when I try to link SFML libraries I get an error closing my game. An Access Violation Memory when it tries to delete a unique_ptr I have in my ResourceManager.

Any clue why? Can I fix it?

Here's my github : https://github.com/NiGhMa/Asteroid

PS: For the moment I link dynamically the SFML libraries

Title: Re: Static linking
Post by: eXpl0it3r on October 08, 2017, 12:54:34 pm
What's the call stack when it crashes?
Title: Re: Static linking
Post by: dabbertorres on October 09, 2017, 08:00:54 pm
SFML types aren't supported in a static context, due to undefined behavior of initialization/de-initialization order.

I bet if you make your SFML objects in Configuration (https://github.com/NiGhMa/Asteroid/blob/master/Asteroid/Configuration.h#L97-L99) non-static, you won't have any more issues.

For reference, see this post (https://en.sfml-dev.org/forums/index.php?topic=7276.msg48046#msg48046) by Tank.