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

Author Topic: sf::Text setString() crash  (Read 3524 times)

0 Members and 4 Guests are viewing this topic.

DxE

  • Newbie
  • *
  • Posts: 22
    • View Profile
sf::Text setString() crash
« on: January 17, 2014, 11:02:04 am »
Ok so I'm relatively new to programming (and even more so to games programming), having moved onto SFML from SDL. I'm using Code::Blocks 13.12 and downloaded "GCC 4.7 MinGW (DW2) - 32 bits" from the SFML 2.1 Downloads section, however when making a very simple test for making and drawing text I get a crash (Text Test.exe has stopped working) when I use the setString function.

Here is my code:
#include <SFML\Graphics.hpp>
#include <iostream>

sf::RenderWindow window;

int main(){
    window.create(sf::VideoMode(640, 480), "Text Test");

    sf::Font foBasic;
    if(!foBasic.loadFromFile("basic.ttf")){
        std::cout << "Could not load font :(\n";
    }
    sf::Text myText;
    myText.setFont(foBasic);
    std::cout << "font set\n";

    myText.setString("pls wurk");  
//^Commenting this out makes the program run, although there is no text to draw so the screen stays blank
    std::cout << "string set\n";

    myText.setCharacterSize(24);
    myText.setColor(sf::Color(255, 255, 100));
    myText.setPosition(0, 0);

    while(window.isOpen()){
        sf::Event event;
        while(window.pollEvent(event)){
            if(event.type==sf::Event::Closed){
                window.close();
            }
        }
        window.clear();
        window.draw(myText);
        window.display();
    }
    return 0;
}
 

The output I get before the crash is "font set".

My search directories are correct and my linker settings are as follows:
C:\SFML-2.1\lib\libsfml-graphics.a
C:\SFML-2.1\lib\libsfml-main.a
C:\SFML-2.1\lib\libsfml-system.a
C:\SFML-2.1\lib\libsfml-window.a

My build target is Release. I have used many other features SFML offers without any errors like this so this particular issue seems weird since I can't find anything about it anywhere. Any help is appreciated  ;D

EDIT:
This is apparently the same as my issue https://github.com/SFML/SFML/issues/5
However I don't really understand the solution and it sounds like that particular issue is specifically for Mac whereas I am on Windows 7.
« Last Edit: January 17, 2014, 11:06:49 am by DxE »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: sf::Text setString() crash
« Reply #1 on: January 17, 2014, 11:31:26 am »
This is apparently the same as my issue https://github.com/SFML/SFML/issues/5
However I don't really understand the solution and it sounds like that particular issue is specifically for Mac whereas I am on Windows 7.
That's a different issue.

I'm using Code::Blocks 13.12 and downloaded "GCC 4.7 MinGW (DW2) - 32 bits" from the SFML 2.1 Downloads section
Ever thought about that the package doesn't match your compiler? ::)

The codeblocks-13.12mingw-setup-TDM-GCC-481.exe file includes the TDM-GCC compiler, version 4.8.1, 32 bit.

You'll need to recompile SFML from source to use it with that compiler!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DxE

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: sf::Text setString() crash
« Reply #2 on: January 17, 2014, 11:43:22 am »
This is apparently the same as my issue https://github.com/SFML/SFML/issues/5
However I don't really understand the solution and it sounds like that particular issue is specifically for Mac whereas I am on Windows 7.
That's a different issue.

I'm using Code::Blocks 13.12 and downloaded "GCC 4.7 MinGW (DW2) - 32 bits" from the SFML 2.1 Downloads section
Ever thought about that the package doesn't match your compiler? ::)

The codeblocks-13.12mingw-setup-TDM-GCC-481.exe file includes the TDM-GCC compiler, version 4.8.1, 32 bit.

You'll need to recompile SFML from source to use it with that compiler!
Oh I reinstalled the latest version of C::B specifically for this and made sure it was "codeblocks-13.12mingw-setup.exe" as I had seen this mentioned on these forums previously (http://en.sfml-dev.org/forums/index.php?topic=13997.0) yet I am still receiving this same error. :S

There is one incompatibility thing that comes to mind though, that would be the .dlls I've put with the program itself (as I was previously using a build of SFML compiled in CMake for the TDM-GCC thing until I received this error and thought updating stuff and using the packages built by people who know what they're doing would possibly fix things) so I will check that now. :)

DxE

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: sf::Text setString() crash
« Reply #3 on: January 17, 2014, 11:52:26 am »
Ok, well it definitely changed something, however I'm now receiving "The procedure entry point __gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll" which, from what I have read, means there is a compatibility issue between my compiler and the package.

Just to clarify, if everything I say I've done is correct then this shouldn't be appearing and I've done one or more steps wrong, right?

EDIT:
Ok it was a compatibility issue, I had been using SFML 2.1 "GCC 4.7 MinGW (DW2) - 32 bits" which made sense since I had intentionally installed C::B without the TDM-GCC jam and MinGW seemed like the obvious alternative but, in fact, I had to download the "GCC 4.7 TDM (SJLJ) - 32 bits" build of SFML which seems a bit weird to me but ok, the problem is solved!
« Last Edit: January 17, 2014, 12:51:17 pm by DxE »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: sf::Text setString() crash
« Reply #4 on: January 17, 2014, 12:49:24 pm »
Looks like I didn't notice that 13.12 was a new version at that time...

As I said here however, you'll need to rebuild SFML to use it with the MinGW version provided for C::B 13.12.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DxE

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: sf::Text setString() crash
« Reply #5 on: January 17, 2014, 01:00:59 pm »
Looks like I didn't notice that 13.12 was a new version at that time...

As I said here however, you'll need to rebuild SFML to use it with the MinGW version provided for C::B 13.12.
Well, as I've detailed in my edit on my previous post (didn't want to triple post) I've got C::B working with the prebuilt TDM-GCC 32 bit build of SFML 2.1.

Should I rebuild SFML anyway just for safety anyway or should I just wait and see if anything crops up?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: sf::Text setString() crash
« Reply #6 on: January 17, 2014, 02:54:33 pm »
It's good to rebuild, but you can also just run it, until it crashes and only then rebuild. :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/