SFML community forums

Help => General => Topic started by: taliebram on June 22, 2021, 03:20:10 pm

Title: Code crashes upon using font.loadFromFile
Post by: taliebram on June 22, 2021, 03:20:10 pm
Hello,


I'm currently working on a project, and until now I have not had any issues with the SFML library. I am currently trying to add some text to my window, but loading in any font results in an instant crash. I have double-checked the linking of the libraries to make sure that I am using -d as I am in debug mode.

I have also tried adding the full path, but that also results in a crash. Using the sf::Text without loading in any font just results in a single pixel being drawn.

I have also tried using different fonts, but that also did not work.

I can add a code snippet, but I have tried it in a small test script where it also fails. I am using the ImGUI::SFML combination, but I don't see how that could be of any influence. I have tried everything I could find online, but I can't find any solution.


Anybody who could help me, I have been stuck for almost a whole day on this now?

This is the error I get when running it in debug mode:
Quote
Unhandled exception at 0x00007FFEC332A1CB (ucrtbased.dll) in OnlineSpikes.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

I am using Visual Studio 2017. and using SFML 2.5.1



Below are the library dependencies I have:

Title: Re: Code crashes upon using font.loadFromFile
Post by: kojack on June 22, 2021, 08:40:49 pm
You have only a single back slash between src and Roboto.
A single backslash will attach to the next character (the R) and change it, so the name is invalid.
Title: Re: Code crashes upon using font.loadFromFile
Post by: taliebram on June 23, 2021, 09:21:16 am
Oh that was a mistype from me, but I already tried about all input configurations (I changed the screenshot).

 The code also just instantly crashes, and you would expect the code just to continue, it does not matter what kind of input I give the font.loadFromFile() function. I did do some reading and everyone who had the same problem could fix it by using the correct dependencies, but I am already doing that (I think, see first screenshot).

So I do not know what to do, anybody who can help me?
Title: Re: Code crashes upon using font.loadFromFile
Post by: taliebram on June 23, 2021, 11:51:11 am
I do not know what the problem is, but for now I bypassed the loadingfromfile, by loading in form memory. This works fine, but now when I pass a std::string to text.setString() the program crashes. I also tried converting a std::string to a sf::string, which also resulted in a crash. It does not crash when it gets char arrays.
Title: Re: Code crashes upon using font.loadFromFile
Post by: Stauricus on June 23, 2021, 01:19:36 pm
i'm going to ask same thing expl0it3r always does:  ;D
what SFML package did you download? are you sure you downloaded the correct version for your architecture (64 / 32 bits)?
Title: Re: Code crashes upon using font.loadFromFile
Post by: taliebram on June 24, 2021, 09:36:47 am
Yes, I even redownloaded it to make sure (2017 MVS 64 bit version), but still did not fix the problem. However, I did bypass it by using the loadfromMemory, and apparently the setString() does work with c strings, so I made it work.

Doesn't seem like a long term solution, but my relatively simple program is almost finished so I am also less inclined to stop looking for a solution.
Title: Re: Code crashes upon using font.loadFromFile
Post by: Stauricus on June 24, 2021, 12:37:20 pm
well, that doesn't seems like a solution.
maybe we can help if you put the code.
and does it work when loading textures from file?
Title: Re: Code crashes upon using font.loadFromFile
Post by: eXpl0it3r on June 24, 2021, 01:01:51 pm
i'm going to ask same thing expl0it3r always does:  ;D
what SFML package did you download? are you sure you downloaded the correct version for your architecture (64 / 32 bits)?
Hehe, that's a good hint ;)

Even though you said, you downloaded the 64bit version, are you also using the 64 compiler in Visual Studio?
Title: Re: Code crashes upon using font.loadFromFile
Post by: taliebram on June 25, 2021, 01:50:59 pm
I'm fairly new to c++ and MVS, but I assume I am if these are enabled:


Title: Re: Code crashes upon using font.loadFromFile
Post by: eXpl0it3r on June 25, 2021, 03:55:30 pm
Please provide the verbose built output: https://www.sfml-dev.org/faq.php#tr-grl-verbose-ide