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

Author Topic: examples not working  (Read 3147 times)

0 Members and 1 Guest are viewing this topic.

mnr

  • Newbie
  • *
  • Posts: 2
    • View Profile
examples not working
« on: June 26, 2021, 04:38:15 pm »
Dear sfml community,

I am trying to build SFML from sources on windows, using cmake and mingw32 and mingw32-make all. I followed the tutorial on the sfml website that explains this (https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php and https://github.com/SFML/SFML/wiki/Tutorial%3A-Build-SFML-with-a-MinGW-Compiler).

I have the impression that during compiling all goes well (both for static and shared libraries). However, from the example directory, apart from the one called "window" (rotating cube) none of the examples actually work (island, joystick, opengl, ....) in the sfml-build/examples folder.

For each one the window opens and then quickly closes again.

I have tried looking online what could be wrong, but since I have no error message to search for, I don't know where to look.

My best guess is that maybe some dll file is missing, or perhaps it is compiled with the wrong compiler and then crashes upon loading. But, as explained above, I have compiled from sources with mingw , so I should have the correction versions of the dll's.

Behavior with static or shared compiling is exactly the same: Only the example called "window" works. (Except, in the shared case the examples first complain that they need the dll's, which after copying into the example folder no longer complain)

My compiler version is 11.1.0 (output of gcc -v; target: x86_64-w64-mingw32)

Any ideas on what could be wrong are greatly appreciated!


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: examples not working
« Reply #1 on: June 30, 2021, 02:19:29 pm »
If you didn't mingw32-make install target, and just launch the examples from the build directory, you'll be missing all the resources which then fails, while outputting error messages on the std::cerr
If you launch if from a terminal window, you should be seeing the error messages.

Note: Any application which uses sfml-audio will require the OpenAL DLL

If in doubt, you can also attach a debugger and see what happens exactly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mnr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: examples not working
« Reply #2 on: July 01, 2021, 09:38:15 am »
Thank you eXpl0itr3r, the idiot I am I didn't think of running the program via the command line to get the error message.

I just record my solution here, in case somebody else runs into a similar problem (or I run into it again in a couple of years from now)

So here is the solution for the problem I had:

open a command prompt, and CD to the examples dir, e.g. go to opengl\

Then run opengl > a.txt 2>&1

(I needed to include the magic > a.txt 2>&1 in order to catch the error message, otherwise the program crashes without an error statement, for whatever reason)

The error is now in a.txt , which was in my case "Failed to load image "resources/background.jpg". Reason: Unable to open file"

The problem is now obvious : I compiled using cmake to a build dir which was not the same as the resources dir. The stuff in resources/ was not copied over, so the program couldn't find background.jpg (and the other stuff) and therefore crashed.





 

anything