SFML community forums

Help => Graphics => Topic started by: mnajrg on November 19, 2012, 09:00:24 am

Title: Help in sf::text
Post by: mnajrg on November 19, 2012, 09:00:24 am
This is my code and I got the error
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(640,480), "Test");
    sf::Font font;
    if(!font.loadFromFile("arial.ttf"))
        return EXIT_FAILURE;

    sf::Text text;
    text.setString("Hello");
    text.setFont(font);
    text.setCharacterSize(30);
    text.setStyle(sf::Text::Bold);
    text.setColor(sf::Color::Red);

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
            window.close();
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
            window.close();
        }
        window.clear(sf::Color::Black);
        window.draw(text);
        window.display();
    }

}
 

Quote
obj\Debug\Main.o||In function `main':|
C:\Documents and Settings\TAE\My Documents\SFML\SAMPLE\Main.cpp|11|undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
||=== Build finished: 1 errors, 0 warnings ===|
Title: Re: Help in sf::text
Post by: Laurent on November 19, 2012, 10:33:10 am
Compiler? Version of SFML? Project settings?
Title: Re: Help in sf::text
Post by: mnajrg on November 19, 2012, 11:48:02 am
Im using code::blocks 10.05 with minggw
and sfml 2.0



[attachment deleted by admin]
Title: Re: Help in sf::text
Post by: Laurent on November 19, 2012, 11:50:59 am
You must link to sfml-system. And don't link to the same libraries in both Debug and Release mode: in Debug you must link to debug libraries (-d suffix).
Title: Re: Help in sf::text
Post by: mnajrg on November 19, 2012, 12:02:54 pm
Thank you so much, I didnt know that I have to link sfml-system because sf::Text is part of sfml graphics module.
Title: AW: Re: Help in sf::text
Post by: eXpl0it3r on November 19, 2012, 12:49:07 pm
Thank you so much, I didnt know that I have to link sfml-system because sf::Text is part of sfml graphics module.
But sf::String (as complained about by the linker) is in the system module and also alot of other badic ghongs like sf::Vector2. The graphics module depends on the window module and both depend on the system module. ;)