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

Author Topic: Help in sf::text  (Read 2388 times)

0 Members and 1 Guest are viewing this topic.

mnajrg

  • Newbie
  • *
  • Posts: 26
    • View Profile
Help in sf::text
« 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 ===|
« Last Edit: November 19, 2012, 10:30:34 am by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help in sf::text
« Reply #1 on: November 19, 2012, 10:33:10 am »
Compiler? Version of SFML? Project settings?
Laurent Gomila - SFML developer

mnajrg

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Help in sf::text
« Reply #2 on: November 19, 2012, 11:48:02 am »
Im using code::blocks 10.05 with minggw
and sfml 2.0



[attachment deleted by admin]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help in sf::text
« Reply #3 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).
Laurent Gomila - SFML developer

mnajrg

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Help in sf::text
« Reply #4 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Re: Help in sf::text
« Reply #5 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/