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

Author Topic: Crash on font.loadFromFile()  (Read 3182 times)

0 Members and 1 Guest are viewing this topic.

Fedcomp

  • Newbie
  • *
  • Posts: 4
    • View Profile
Crash on font.loadFromFile()
« on: November 06, 2013, 09:37:35 am »
Hello sfml forums!

When i try to use font.loadFromFile() with correct/incorrect path in release configuration it crashes the application.
Example code:
int Game::Run(){
// ...
                sf::Font font;
                font.loadFromFile("arial.ttf");
// gameloop
}

BUT! it only happens in release mode! Not even message like "cannot load the font %font name%". When i using debug configuration _everything_ works fine, i can display text, i can use my own custom font etc. Even if i only add thoose two lines (the code above) and not using them, it still crash the game, for some reason sf::font crashes the application in release mode during loadFromFile().
In release configuration drawing sprites and camera and keyboard is working, so i guess everything else is working correct except Font. I have googled a bit and found that sfml font had issues with crash before, but it seems has been fixed. However it happens with me.

OS: Windows 7 x64
Compiler: Cmake + Mingw
SFML: version 2, statically linked to the project.
IDE: Codeblocks project made by cmake.
All software - mingw,code::blocks,cmake,sfml is freshly downloaded 3-6 days ago (in case with sfml is SFML Sources on download page)

If i compile SFML in debug or release configuration, nothing is changing. I haven't tryed to dynamically link sfml libs, but i think if everything else is working, and even font is working in debug configuration, it's not an issue.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: Crash on font.loadFromFile()
« Reply #1 on: November 06, 2013, 11:16:31 am »
Are you using the debug libraries in release mode? If so, don't! You need to use the release libraries (without -d suffix) in release mode. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Fedcomp

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Crash on font.loadFromFile()
« Reply #2 on: November 06, 2013, 03:02:37 pm »
As i already said, it doesn't matter what kind of binaries i use. Fonts start working when i run project using codeblocks debug, and when running using windows explorer or just in release mode using codeblocks they crash the application.
Not to say cmake find_files finding appropriate libs to link (with correct suffixes).
It's more of an issue "why it works under gdb and not works when run without it".

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: Crash on font.loadFromFile()
« Reply #3 on: November 06, 2013, 03:21:10 pm »
As i already said, it doesn't matter what kind of binaries i use.
You never said that, you've always just referred to debug and release mode, which is something else than using debug and release libraries.
From your description I'm still not sure whether you've fully understood the difference, especially since you've now started mixing states.

If you build your application in debug mode, do you link the debug libraries (with -d suffix)?
If you build your application in release mode, do you link the release libraries (without -d suffix)?
Does the application in debug mode with debug libraries run in GDB?
Does the application in debug mode with debug libraries run outside of GDB?
Does the application in release mode with release libraries run in GDB?
Does the application in release mode with release libraries run outside of GDB?

Not to say cmake find_files finding appropriate libs to link (with correct suffixes).
It's more of an issue "why it works under gdb and not works when run without it".
I hope you looked at the advanced options, because CMake doesn't always do what one wishes it would. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Fedcomp

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Crash on font.loadFromFile()
« Reply #4 on: November 08, 2013, 05:46:35 pm »
You never said that, you've always just referred to debug and release mode, which is something else than using debug and release libraries.
From your description I'm still not sure whether you've fully understood the difference, especially since you've now started mixing states.
I dont mix the states, when i run release mode and haven't build release libraries cmake show me error,
because cmake find_file with your module can't find appropriate libs.
So no, cmake find_file searching for appropriate libs.

I hope you looked at the advanced options, because CMake doesn't always do what one wishes it would. ;)
Advanced options is inspecting find_file myself? already done, i spen't quite some time setting build environment,
and figuring out how to build SFML. Glad such nice framework exist, i hate dealing with SDL, it's pointers etc.

P.S. Topic can be closed, the error was in small piece of code working with Vector lines, i didn't paid enough attention to that lines.
Sorry for inconvenience, everything is working.

P.P.S. but why GDB fix problems with pointers?
« Last Edit: November 08, 2013, 05:49:37 pm by Fedcomp »